1、信号处理上机实验结果实验一1 连续信号(1)指数信号A=1;a=-0.4;t=0:0.01:10;ft=A*exp(a*t);plot(t,ft);grid;axis(0 10 -0.1 1.1);(2) 正弦信号A=1;w0=2*pi;phi=pi/6;t=0:0.01:3;ft=A*sin(w0*t+phi);plot(t,ft);grid;axis(0 3 -1.1 1.1);(3)抽样信号x=linspace(-20,20); y=sinc(x/pi);plot(x,y) grid;axis(-21 21 -0.5 1.1);(4)矩形脉冲t=0:0.001:4;T=1;ft=rect
2、puls(t-2*T,2*T);plot(t,ft);grid;axis(-1 5 -0.1 1.1);(5)阶跃信号function f=Heaviside(t) f=(t0)-t=-1:0.001:3;ft=Heaviside(t);plot(t,ft);grid;axis(-1 3 -0.1 (6)复指数信号的时域波形t=0:0.1:60;f=exp(-0.1*t).*sin(2/3*t); plot(t,f);grid;ylabel(f(t);xlabel(Time(sec);axis(0 60 -1 1);(7)加入随机噪声的正弦波 t=(0:0.001:50);y=sin(2*pi
3、*50*t);s=y+randn(size(t);Subplot(2,1,1);plot(t(1:100),y(1:100);Subplot(2,1,2);plot(t(1:100),s(1:100); (8)周期矩形波t=(0:0.0001:5);A=1;y=A*square(2*pi*t,20); plot(t,y);axis(0 5 -1.5 1.5)2 信号的基本运算设 求出syms t;f=sym(t/2+1)*(heaviside(t+2)-heaviside(t-2);subplot(2,3,1),ezplot(f,-3,3); title(f(t);grid;y1=subs(f
4、,t,t+2);subplot(2,3,2),ezplot(y1,-5,1);title(f(t+2);grid;y2=subs(f,t,t-2);subplot(2,3,3),ezplot(y2,-1,5);title(f(t-2);grid;y3=subs(f,t,-t);subplot(2,3,4),ezplot(y3,-3,3);title(f(-2t);grid;y4=subs(f,t,2*t);实验二例1 求系统y”(t)+2y(t)+100y(t)=10f(t)的零状态响应,已知f(t)=(sin2t)(t)。 ts=0;te=5;dt=0.01; sys=tf(10,1 2 1
5、00); t=ts:dt:te; f=10*sin(2*pi*t); y=lsim(sys,f,t); plot(t,y); xlabel(Time(sec) ylabel(y(t)例2 求系统y”(t)+2y(t)+100y(t)=10f(t)的零状态响应,已知f(t)= (t)。ts=0;te=5;dt=0.01; sys=tf(10,1 2 100); t=ts:dt:te; y=impulse(sys,t); plot(t,y); xlabel(Time(sec) ylabel(h(t)实验三例1试用MATLAB画出图示周期三角波信号的频谱解:周期信号的频谱为N=8; n1=-N:-1
6、; %计算n=-N到-1的Fourier系数 c1=-4*j*sin(n1*pi/2)/pi2./n1.2; c0=0; %计算n=0时的Fourier系数n2=1:N; %计算n=1到N的Fourier系数c2=-4*j*sin(n2*pi/2)/pi2./n2.2; cn=c1 c0 c2; n=-N:N; subplot(2,1,1); stem(n,abs(cn);ylabel(Cn的幅度); subplot(2,1,2); stem(n,angle(cn); ylabel(Cn的相位);xlabel(omega/omega0);例2求周期矩形脉冲的Fourier级数表示式。并用MAT
7、LAB求出由前N项Fourier级数系数得出的信号近似波形。取A=1, T=2, t=1, w0=p t=-2:0.001:2; N=input(Number of harmonics= ); c0=0.5; xN=c0*ones(1,length(t); %dc component for n=1:2:N xN=xN+cos(pi*n*t)*sinc(n/2); end plot(t,xN); title(N= num2str(N); N=5 N=15N N=50 N=500例试用数值方法近似计算三角波信号的频谱解: 图示三角波可表示为三角波信号频谱的理论值为F(jw)= Sa2(w / 2)w=linspace(-6*pi,6*pi,512); N=length(w);F=zeros(1,N);for k=1:NF(k)=quad(sf1,-1,1,w(k);endfigure(1); plot(w,real(F); F=zeros(1,N); title(); xlabel(omega); ylabel(omega);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1