stft_complex
Description
Performs Short-Time-Fourier-Transform on a 1d signal(complex data).
Syntax
int stft_complex( vector<complex> & vSignal, vector & vWin, double dSmplIntv, int nOverlap, int nFFTPts, matrix<complex> & matSTFT, matrix & matAmp, double & dScaleTime, double & dScaleFreq )
Parameters
- vSignal
- [Input] the complex 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 complex result of STFT spectrum with time arraged in column wise and the frequency row wise.
- matAmp
- [Output] the amplitude result matrix.
- 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 <Origin.h>
#include <fft_utils.h>
#include <fftEx_utils.h>
void stft_complex_ex1()
{
vector win(4);
vector sig_re(8) = {0, 0, 0, 1, 1, 0, 0, 0};
vector sig_im(8) = {0, 0, 0, 1, 1, 1, 0, 0};
vector<complex> sig(8);
sig.MakeComplex(sig_re, sig_im);
get_window_data(RECTANGLE_WIN, 4, win);
matrix<complex> stft;
matrix amp;
double stime;
double sfreq;
stft_complex(sig, win, 0.1, 1, 4, stft, amp, 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+%lfi\t", stft[ii][jj].m_re, stft[ii][jj].m_im);
printf ("\n");
}
}
Remark
See Also
stft_real
header to Include
fftEx_utils.h
Reference
|