【发布时间】:2014-02-25 08:39:24
【问题描述】:
我生成了以下时间信号:
现在我想使用 matlab 命令fft 执行离散傅里叶变换
这是我的代码:
function [ xdft, omega ] = FastFourier( t, fs )
%% Inputs from other functions %%
[P_mean, x, u] = MyWay( t ) %From here comes my signal x(t)
%% FFT %%
xdft1 = fft(x); % Perform FFT
xdft2 = abs(xdft1); % Take the absolute value of the fft results
xdft = xdft2(1:length(x)/2+1); % FFT is symmetric, second half is not needed
freq = 0:fs/length(x):fs/2; % frequency axis
plot (freq(1:100),xdft(1:100));
end
这是我得到的情节:
让我感到困惑的是y 轴? y 轴不应该代表频率分量的幅度吗?有没有办法得到所有频率分量的幅度?
谢谢!
编辑: 我发现有些人会这样做:
n = size(x,2)/2; %The number of components and second half can be neglected again
xdft2 = abs(xdft1)/n;
这样我似乎得到了幅度谱,但是为什么我必须将绝对值除以n?
【问题讨论】:
-
可以在相关问题中找到更多答案 (dsp.stackexchange.com/questions/14636/…)