当前位置:文档之家› MATLAB实验二傅里叶分析及应用

MATLAB实验二傅里叶分析及应用

实验二傅里叶分析及应用、实验目的(一)掌握使用Matlab 进行周期信号傅里叶级数展开和频谱分析1、学会使用Matlab 分析傅里叶级数展开,深入理解傅里叶级数的物理含义2、学会使用Matlab 分析周期信号的频谱特性二)掌握使用Matlab 求解信号的傅里叶变换并分析傅里叶变换的性质1、学会运用Matlab 求连续时间信号的傅里叶变换2、学会运用Matlab 求连续时间信号的频谱图3、学会运用Matlab 分析连续时间信号的傅里叶变换的性质三)掌握使用Matlab 完成信号抽样并验证抽样定理1、学会运用MATLAB 完成信号抽样以及对抽样信号的频谱进行分析2、学会运用MATLAB 改变抽样时间间隔,观察抽样后信号的频谱变化3、学会运用MATLAB 对抽样后的信号进行重建、实验条件Win7系统,MATLAB R2015a三、实验内容1、分别利用Matlab 符号运算求解法和数值计算法求下图所示信号的FT,并画出其频谱图(包括幅度谱和相位谱)[注:图中时间单位为:毫秒(ms)]。

Code:ft = sym( '(t+2)*(heaviside(t+2)-heaviside(t+1))+(heaviside(t+1)-heav iside(t-1))+(2-t)*(heaviside( t-1)-heaviside(t-2))' ); fw = simplify(fourier(ft));subplot(2, 1, 1); ezplot(abs(fw)); grid on;title( 'amp spectrum' ); phi =atan(imag(fw) / real(fw));subplot(2, 1, 2);ezplot(phi); grid on ;title( 'phase spectrum' );符号运算法Code:dt = 0.01;t = -2: dt: 2;ft(t+2).*(uCT(t+2)-uCT(t+1))+(u CT(t+1)-uCT(t-1))+(2-t).*(uCT (t-1)-uCT(t-2));N = 2000; k = -N: N;w = pi * k / (N*dt); fw =dt*ft*exp(-i*t'*w);fw = abs(fw); plot(w, fw),grid on;axis([-2*pi 2*pi -1 3.5]);数值运算法2、试用 Matlab 命令求 F(j ) 10- 4的傅里叶反变换,并绘出其时域信号图 3 j 5 j两个单边指数脉冲的叠加Code :f = sym( 'heaviside(t+1) - heaviside(t-1)' ); fw = simplify(fourier(f)); F = fw.*fw; subplot(211); ezplot(abs(F), [-9, 9]), grid on title( 'FW^2' ) tri =sym( '(t+2)*heaviside(t+2)-2*t*heaviside(t)+(t-2)*heaviside(t-2)' ); Ftri = fourier(tri); F = simplify(Ftri); subplot(212); ezplot(abs(F), [-9, 9]), grid o n ; title( 'tri FT' )Code : syms t ; fw =sym( '10/(3+i*w)-4/(5+i* w)' );ft = ifourier(fw, t); ezplot(ft), grid on;3、已知门函数自身卷积为三角波信号,试用 Matlab命令验证 FT 的时域卷积定理 (20 exp(-3 t) heaviside(t) - 8 exp(-5 t) heaviside(t))/( 2 )4、设有两个不同频率的余弦信号,频率分别为 f1 100Hz , f2 3800Hz ;现在使用抽样频率 f s 4000Hz 对这三个信号进行抽样,使用MATLAB命令画出各抽样信号的波形和频谱,并分析其频率混叠现象Cosine curveTime/s -3x 10432110-3x 10 Sample freq spectrum-3x 10 Cos freq spectrum-2Sample signalTime/s -3x 10wf sf1 =100Hz将代码中f1 设为3800即可↓Cosine curvex 10)40-2-3x 10 Cos freq spectrumSample signalx 10x 10x 10f2 =3800Hz5、结合抽样定理,利用 MATLAB 编程实现 Sa(t) 信号经过冲激脉冲抽样后得到的抽样信号 f s t 及其频谱[建议:冲激脉冲的周期分别取 4*pi/3 s 、pi s 、2*pi/3 s三种情况对比 ],并利用 f s t 构建Sa(t )信号** 改动第一行代码即可)t2 = -5: Ts: 5; fst = sinc(t2); subplot(2, 2, 3) plot(t1, ft, ':' ), hold on stem(t2, fst), grid on axis([-6 6 -0.5 1.2]) title( 'Sampling signal' ) Fsw = Ts*fst*exp(-1i*t2'*W); subplot(2, 2, 4) plot(W, abs(Fsw)), grid on axis([-50 50 -0.05 1.5]) title( 'spectrum of Sampling signal' )冲激脉冲的周期= 4*pi/3 sSa(t)Sa(t) freq spectrumSampling signal spectrum of Sampling signalTs = 4/3; % impulse period = 4*pi/3 t1 = -5:0.01:5;ft = sinc(t1); subplot(2, 2, 1) plot(t1, ft), gridonaxis([-6 6 -0.5 1.2]) title( 'Sa(t)' ) N = 500; k = -N: N; W = pi*k / (N*0.01);Fw = 0.01*ft*exp(-1i*t1'*W); subplot(2, 2, 2)plot(W, abs(Fw)), grid on axis([-30 30-0.05 1.5])title( 'Sa(t) freq spectrum')Sa(t) freq spectrum10.5 0 -20 0 20冲激脉冲的周期 = pi sSamplingsignal spectrum of Sampling signalSa(t)Sa(t) freqspectrumSampling signal spectrum of Sampling signal1.5Sa(t)冲激脉冲的周期= 2*pi/3 s1)试求出该信号的傅里叶级数[自己求或参见课本P112或P394],利用Matlab 编程实现其各次谐波[如1、3、5、13、49]的叠加,并验证其收敛性;1a0 =2nπ2sin2(n2π); b n = 0 谐波幅度收敛速度1n2原始波形:1 class H-wave3 class H-wave Originalwave1 10.8 0.80.6 0.60.4 0.40.2 0.20 0-4 -2 0 -2 0 20 -410.80.60.40.213 class H-wave49 class H-wav e10.80.60.40.2第k 阶谐波波形Code:figure(1);t = -2*pi: 0.001: 2*pi;f = abs(sawtooth(0.5*pi*t,0.5)); plot(t, f), grid on ; axis([-4, 4, -1, 2])title( 'Original wave' );nclass = [1, 3, 13, 49]; figure(2);N = 4;a0 = 1/2;for k = 1: Nn = nclass(k);an = 4./((n*pi).^2);ft = an*cos(pi*n'*t);ft = ft + a0;subplot(2, 2, k); plot(t, ft); axis([-4, 4, 0, 1])title([num2str(nclass(k)), class H-wave ' ]); endfigure(3);N = 4; a0 = 1/2;for k = 1: Nn = 1: 2: nclass(k);an = 4./((n*pi).^2);ft = an*cos(pi*n'*t);ft = ft + a0;subplot(2, 2, k); plot(t, ft);axis([-4, 4, 0, 1]) title([ 'The ' ,num2str(nclass(k)), 'times superpose' ]);endThe 1times superpose10.80.60.4The 13times superpose 0.20 -4 -2The 3times superpose0.80.60.40.2-2 2-4The 49times superpose0.80.60.40.2-2-4前K 次谐波的叠加(2)用 Matlab 分析该周期三角信号的频谱 [三角形式或指数形式均可 ]。

当周期三角信 号的周期( 如由 2ms 1ms 或由 2ms 4ms )和宽度( 如2ms 1ms )分别变化时,试观察 分析其频谱的变化。

dt=0.01; t=-4:dt:4;ft=(t>=-1&t<0).*(t+1)+(t>0&t <=1).*(1-t);%subplot(2,1,1)%plot(t,ft);grid on n=2000; k=-n:n; w=pi*k/(n*dt);f=dt*ft*exp(-i*t'*w); f=abs(f); %subplot(2,1,2) plot(w,f);axis([-20 20 0 1.1]),grid on;dt=0.01; t=-4:dt:4;ft=(t>=-0.5&t<0).*(t+1)+(t>0 &t<=0.5).*(1-t);%subplot(2,1,1)%plot(t,ft);grid on n=2000; k=-n:n; w=pi*k/(n*dt);f=dt*ft*exp(-i*t'*w); f=abs(f); %subplot(2,1,2)plot(w,f);axis([-20 20 0 1.1]),grid on;周期为 1ms周期为 2ms-15 -10 -5 10 15 20-020四、实验结论和讨论1、凡是等步长离散采样一定会产生频率混叠现象。

相关主题