我在matlab上执行了阶跃函数FFT,但仅获得了频谱的一侧(0到无穷大) [英] I did a step function FFT on matlab but only getting one side of the spectrum (0 to infinity)
本文介绍了我在matlab上执行了阶跃函数FFT,但仅获得了频谱的一侧(0到无穷大)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用此代码,我只能得到从0到正无穷大的fft频谱的一半.我正在尝试沿y轴镜像此镜像,以使另一半与该对称的从0到负无穷大对称.
with this code i am only getting half og the fft spectrum from 0 to positive infinity . i am trying to mirror this along the y axis to get the other half which is symmetric to this one from 0 to negative infinity.
Fs = 1000; %sampling rate
Ts = 1/Fs; %sampling time interval
t = -10:Ts:10-Ts; %sampling period
n = length(t); %number of samples
y = heaviside(t)-heaviside(t-4); %the step curve
matlabFFT = figure; %create a new figure
YfreqDomain = fft(y); %take the fft of our step funcion, y(t)
y=abs(YfreqDomain);
plot(y)
xlabel('Sample Number')
ylabel('Amplitude')
title('Using the Matlab fft command')
grid
axis([-100,100,0,5000])
推荐答案
这是正常行为. FFT仅以正频率(0到Fs之间)返回频谱.您可以使用fftshift
进行更正.零频率将位于x轴的中心.所以你应该使用
That's normal behaviour. The FFT returns the spectrum in positive frequencies only (between 0 and Fs). You can use fftshift
to correct that. The zero frequency will then be at the center of the x axis. So you should use
plot(fftshift(y))
axis([-100+1e4,100+1e4,0,5000])
这篇关于我在matlab上执行了阶跃函数FFT,但仅获得了频谱的一侧(0到无穷大)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文