【转载】利⽤matlab绘制傅⾥叶分解三维图
⽬的:
理解傅⾥叶变换分析及其他⽅法的分析。
理解傅⾥叶变换频域与时域的关系。
利⽤MATLAB绘制傅⾥叶变换图形三维图。
内容和原理:
本次主要使⽤的函数及其说明如下(此处只取采⽤⽤法的意义说明):
1.abs:abs(X) is the absolute value of the elements of X. When
X is complex, abs(X) is the complex modulus (magnitude) of
the elements of X.
短时傅里叶变换matlab程序2.figure: figure, by itself, creates a new figure window, and returns
its handle.
3.square: square(T) generates a square wave with period 2*Pi for the
elements of time vector T. square(T) is like SIN(T), only
it creates a square wave with peaks of +1 to -1 instead of
a sine wave.
4. Fft: fft(X,N) is the N-point fft, padded with zeros if X has less
than N points and truncated if it has more.
5. plot3:plot3(x,y,z), where x, y and z are three vectors of the same length,
plots a line in 3-space through the points whose coordinates are the
elements of x, y and z.
结果与分析:
根据要求需要⾸先产⽣具有⾜够采样频率的⽅波,我采⽤了square函数⽣成⽅波,频率设置为1Hz,采样频率则为100Hz。接着进⾏傅⾥叶变换,利⽤fft函数,⽣成N个分解波形,N越⼤,分解次数越多,频谱越精密,实验中采⽤N=512进⾏实验。利⽤plot3函数进⾏绘图并投影。
产⽣的⽅波图如下:
产⽣频谱图如下:
绘制三维图像如图:
程序代码如下:
N=512;
fs=100;
t=-2:1/fs:2;
m=square(2*pi*t);
plot(t,m);
axis([-11 -22]);
figure();
title('⽅波');
b=fft(m,N);
mag=abs(b);
plot(mag);
figure();
x=-5:0.01:5;
for i=1:length(b)
for k=1:length(x)
z(k)=abs(b(i))*sin((i-1)*x(k)+angle(b(i))); y(k)=i;
end
figure(3);
grid on;
plot3(x,y,z);
hold on;
x_z=zeros(1,length(x))+6;
plot3(x_z,y,abs(z));
hold on;
end