MATLAB与傅里叶变换:理论与应用

一、运算代码

1、数值计算法求函数傅里叶变换

幅度谱

dt=0.01;
t=-4:dt:4;
ft=(t+2).*(heaviside(t+2)-heaviside(t+1))+heaviside(t+1)-heaviside(t-1)+((-t+2).*(heaviside(t-1)-heaviside(t-2)));
N=2000;
k=-N:N;
W=pi*k/(N*dt);
F=dt*ft*exp(-1j*t'*W);
F=abs(F);
plot(W,F);grid on
axis([-pi pi -1 4]);
xlabel('W'),ylabel('F(W)')
title('amplitude spectrum')

相位谱

dt=0.01;
t=-4:dt:4;
ft=(t+2).*(heaviside(t+2)-heaviside(t+1))+heaviside(t+1)-heaviside(t-1)+((-t+2).*(heaviside(t-1)-heaviside(t-2)));
N=2000;
k=-N:N;
W=pi*k/(N*dt);
F=dt*ft*exp(-1j*t'*W);
F=atan(imag(F)/real(F));
plot(W,F);grid on
axis([-pi pi -1 3]);
xlabel('W'),ylabel('argF(W)')
title('phase spectrum')

2、傅里叶反变换

syms t
Fw=str2sym('10/(3+w*j)-4/(5+w*j)');
ft=ifourier(Fw,t);
subplot(324)
ezplot(ft,[-1.5 1.5]);grid on
axis([-1*pi 1*pi -0.2 2.2])

syms t
Fw=str2sym('exp(-4*(w^2))');
ft=ifourier(Fw,t);
subplot(321)
ezplot(ft,[-1.5 1.5]);grid on
axis([-0.5*pi 0.5*pi -0.1 0.5])

3、符号运算求解法求解傅里叶变换

syms t
ft=str2sym('(t+2)*(heaviside(t+2)-heaviside(t+1))+heaviside(t+1)-heaviside(t-1)+((-t+2)*(heaviside(t-1)-heaviside(t-2)))');
Fw=fourier(ft);
subplot(211)
ezplot(abs(Fw));grid on
title('幅度谱')
phase=atan(imag(Fw)/real(Fw));
subplot(212)
ezplot(phase);grid on
title('相位谱')

4、频率乘积

ft=str2sym('heaviside(t+1)-heaviside(t-1)');
Fw=fourier(ft);
Fw1=Fw*Fw;
subplot(211)
ezplot(abs(Fw1));grid on
title('幅度谱')
phase=atan(imag(Fw1)/real(Fw1));
subplot(212)
ezplot(phase);grid on
title('相位谱')

5、时域卷积

clear;clc
t11=-1; t12=+1;
t21=-1; t22=+1;
t1=t11:0.01:t12;
ft1=heaviside(t1+1)-heaviside(t1-1);
t2=t21:0.01:t22;
ft2=heaviside(t2+1)-heaviside(t2-1);
t3=(t11+t21):0.01:(t12+t22);
ft3=double(conv(ft1,ft2));
ft3=ft3*0.01;
plot(t3,ft3);grid on
axis([-pi pi -1 3]);
xlabel('t'),ylabel('ft')
title('ft1*ft2')
ft=str2sym('(t+2)*(heaviside(t+2)-heaviside(t))+(-t+2)*(heaviside(t)-heaviside(t-2))');
Fw=fourier(ft);
subplot(211)
ezplot(abs(Fw));grid on
title('幅度谱')
phase=atan(imag(Fw)/real(Fw));
subplot(212)
ezplot(phase);grid on
title('相位谱')

5、频域卷积(解决了问题的)

clear;clc
syms t
ft=str2sym('sin(pi*t)/(pi*t)');
Fw=simplify(fourier(ft));
w11=-pi; w12=+pi;
w21=-pi; w22=+pi;
w1=w11:0.01:w12;
Fw1=heaviside(w1+pi)-heaviside(w1-pi);
w2=w21:0.01:w22;
Fw2=heaviside(w2+pi)-heaviside(w2-pi);
w3=(w11+w21):0.01:(w12+w22);
Fw3=double(conv(Fw1,Fw2));
Fw3=Fw3*0.01/(2*pi);
plot(w3,Fw3);grid on
axis([-3*pi 3*pi -1 2]);
xlabel('w'),ylabel('Fw')
title('Fw1*Fw2')
Fw4=str2sym('(((1/(2*pi))*w+1)*(heaviside(w+2*pi)-heaviside(w)))+(((-1/(2*pi))*w+1)*(heaviside(w)-heaviside(w-2*pi)))');
subplot(211)
ezplot(abs(Fw4));grid on
title('幅度谱')
phase=atan(imag(Fw4)/real(Fw4));
subplot(212)
ezplot(phase);grid on
title('相位谱')

二、反思

1、Matlab提倡用fplot去作图,不提倡ezplot;

2、用plot时,括号中的向量必须长度相同;

3、fplot()后面用分号,而不是逗号;

4、数值运算法求出的傅里叶变换可以作图,但是不方便直接写出解析式。

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空