We added following labtalk functions for signal processing: 1. fftc vector<complex> fftc(vector<complex> cx)
It calculates the complex FFT result for given cx. We should use different algorithms depending on whether cx is real. If cx's size is n, then output size is also n. (shift should be off.) 2. fftmag vector fftmag(vector<complex> cx, int side=1 )
It can be used to calculate magnitude from FFT complex result. side=1 for one-sided by default, side=2 for two-sided and shift. 3. fftamp vector fftamp(vector<complex> cx, int side=1 )
It can be used to calculate amplitude from FFT complex result. side=1 for one-sided by default, side=2 for two-sided and shift. 4. fftphase vector fftphase(vector<complex> cx, int side=1, int unwrap=1, int unit=1 )
It can be used to calculate amplitude from FFT complex result. side=1 for one-sided by default, side=2 for two-sided and shift. unwrap=0 not unwrap phase angle, 1 for unwrap by default. unit=1 for degrees unit by default, 0 for radians unit. 5. ifftshift vector<complex> ifftshift(vector<complex> cx)
When fft result is shifted, to do ifft, we need unshift the result first. 6. invfft vector<complex> invfft(vector<complex> cx)
Compute inverse FFT from fft result. If input size is n, output size is n. 7. fftfreq vector fftfreq(double time, int n, int side=1, int shift=1)
Calculate frequencies for FFT results, the original result is time*data(0,n-1) time: sampling interval n: signal size side: 1 for one-sided(by default), 2 for two-sided shift: 0 for no-shift, and 1 for shift(by default), it is used for two-sided. Return frequencies, two-sided size is n, one-sided size is ceil((n+1)/2) 8. fftshift vector<complex> fftshift(vector<complex> cx)
It can be used to shift FFT results or frequency. 9. windata vector windata(int type, int n)
type=0 rectangle, 1: Welch, 2: Triangular, 3: Bartlett, 4: Hanning, 5: Hamming, 6: Blackman n is size for the window. Return a vector of size n. |