matlab中fft命令为何要配合fftshift来用?如题.

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 22:37:48
matlab中fft命令为何要配合fftshift来用?如题.

matlab中fft命令为何要配合fftshift来用?如题.
matlab中fft命令为何要配合fftshift来用?
如题.

matlab中fft命令为何要配合fftshift来用?如题.
fftshift的作用正是让正半轴部分和负半轴部分的图像分别关于各自的中心对称.因为直接用fft得出的数据与频率不是对应的,fftshift可以纠正过来
以下是Matlab的帮助文件中对fftshift的说明:
Y = fftshift(X) rearranges the outputs of fft,fft2,and fftn by moving the zero-frequency component to the center of the array.It is useful for visualizing a Fourier transform with the zero-frequency component in the middle of the spectrum.For vectors,fftshift(X) swaps the left and right halves of X.
例子如下:
clear;
clc;
t=0:0.001:2;
n=2001;
Fs=1000;
Fc=200;
x=cos(2*pi*Fc*t);
y1=fft(x);
y2=fftshift(y1);
f=(0:2000)*Fs/n-Fs/2;
hold on;
plot(f,abs(y1),'r')
plot(f,abs(y2),'b')