Fast Fourier transform 您所在的位置:网站首页 codechomepage Fast Fourier transform

Fast Fourier transform

#Fast Fourier transform| 来源: 网络整理| 查看: 265

Open Live Script

Interpolate the Fourier transform of a signal by padding with zeros.

Specify the parameters of a signal with a sampling frequency of 80 Hz and a signal duration of 0.8 s.

Fs = 80; T = 1/Fs; L = 65; t = (0:L-1)*T;

Create a superposition of a 2 Hz sinusoidal signal and its higher harmonics. The signal contains a 2 Hz cosine wave, a 4 Hz cosine wave, and a 6 Hz sine wave.

X = 3*cos(2*pi*2*t) + 2*cos(2*pi*4*t) + sin(2*pi*6*t);

Plot the signal in the time domain.

plot(t,X) title("Signal superposition in time domain") xlabel("t (ms)") ylabel("X(t)")

Compute the Fourier transform of the signal.

Y = fft(X);

Compute the single-sided amplitude spectrum of the signal.

f = Fs*(0:(L-1)/2)/L; P2 = abs(Y/L); P1 = P2(1:(L+1)/2); P1(2:end) = 2*P1(2:end);

In the frequency domain, plot the single-sided spectrum. Because the time sampling of the signal is quite short, the frequency resolution of the Fourier transform is not precise enough to show the peak frequency near 4 Hz.

plot(f,P1,"-o") title("Single-Sided Spectrum of Original Signal") xlabel("f (Hz)") ylabel("|P1(f)|")

To better assess the peak frequencies, you can increase the length of the analysis window by padding the original signal with zeros. This method automatically interpolates the Fourier transform of the signal with a more precise frequency resolution.

Identify a new input length that is the next power of 2 from the original signal length. Pad the signal X with trailing zeros to extend its length. Compute the Fourier transform of the zero-padded signal.

n = 2^nextpow2(L); Y = fft(X,n);

Compute the single-sided amplitude spectrum of the padded signal. Because the signal length n increased from 65 to 128, the frequency resolution becomes Fs/n, which is 0.625 Hz.

f = Fs*(0:(n/2))/n; P2 = abs(Y/L); P1 = P2(1:n/2+1); P1(2:end-1) = 2*P1(2:end-1);

Plot the single-sided spectrum of the padded signal. This new spectrum shows the peak frequencies near 2 Hz, 4 Hz, and 6 Hz within the frequency resolution of 0.625 Hz.

plot(f,P1,"-o") title("Single-Sided Spectrum of Padded Signal") xlabel("f (Hz)") ylabel("|P1(f)|")



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有