2.1.22.2.1.49 stft_real


Description

Performs Short-Time-Fourier-Transform on a 1d signal(real data). It computes the windowed discrete-time Fourier transform of a signal using a sliding window. It return the power spectrum from the signal sequence and time and frequence scales as well

Syntax

int stft_real( vector & vSignal, vector & vWin, double dSmplIntv, int nOverlap, int nFFTPts, matrix & matSTFT, double & dScaleTime, double & dScaleFreq )

Parameters

vSignal
[Input] the real vector of original signal
vWin
[Input] the vector of Window data
dSmplIntv
[Input] the Sample interval of signal data
nOverlap
[Input] the overlaping points of adjacent window
nFFTPts
[Input] the number of points in FFT
matSTFT
[Output] the result STFT spectrum with time arraged in column wise and the amplitude of each frequency row wise.
dScaleTime
[Output] the maximum time of the STFT spectrum, it's also the XMax of matSTFT
dScaleFreq
[Output] the maximum frequency of the STFT spectrum, it's also the YMax of matSTFT

Return

0 for success or error codes.

Examples

Prior to compilation, load fftEx_utils.c to the workspace by executing the following LabTalk command:

Run.LoadOC("Originlab\fftEx_utils.c", 16);

To retain fftEx_utils.c in the workspace for successive sessions, drag and drop the file from the Temporary folder to the System folder.

EX1

#include <fft_utils.h>
#include <fftex_utils.h>
void stft_real_ex1()
{
    vector win(4);
    vector sig(8) = {0, 0, 0, 1, 1, 0, 0, 0};
    get_window_data(RECTANGLE_WIN, 4, win);
    matrix stft;
    double stime;
    double sfreq;
    stft_real(sig, win, 0.1, 1, 4, stft, stime, sfreq);
    int row = stft.GetNumRows();
    int col = stft.GetNumCols();
    for (int ii=0; ii<row; ii++)
    {
        for (int jj=0; jj<col; jj++)
            printf ("%lf\t", stft[ii][jj]);
        printf ("\n");
    }
}

Remark

See Also

stft_complex

Header to Include

fftEx_utils.h

Reference