【发布时间】:2014-12-29 10:23:09
【问题描述】:
在下面的代码中,我试图获取固定信号 (x3) 的 fourier transform。但是在运行时,我得到的图绝对是错误的,并且没有显示信号 x3 的任何频率。
请指导我并帮助我正确获取fourier transform。
代码:
%% Time specifications:
Fs = 8000; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 1; % seconds
t = (0:dt:StopTime-dt); % seconds
x1 = (10)*cos(2*pi*3*(t));
x2 = x1 + (10)*cos(2*pi*5*(t));
x3 = x2 + (10)*cos(2*pi*10*(t));
%% here i try to Plot fourier transform of the signal x3:
NFFT = 2^nextpow2(StopTime); % Next power of 2 from length of y
Y = fft(y,NFFT)/StopTime;
f = Fs/2*linspace(0,1,NFFT/2+1);
figure;
plot(f,2*abs(Y(1:NFFT/2+1)));
%% Plot the signal versus time:
figure;
hold on;
plot(t,x1,'r');
plot(t,x2,'g');
plot(t,x3,'b');
Update_1
【问题讨论】:
-
为什么要用
StopTime缩放FFT?如果您希望时域中的能量等于频域中的能量,则必须按Fs缩放。
标签: matlab signal-processing fft wavelet