1、实验二 连续信号基本运算的MATLAB实现一、实验目的1、观察并熟悉连续信号的波形和特性。2、学会运用Matlab表示常用连续时间信号的基本运算。二、实验原理(1)信号的基本加法和乘法运算:f1=sin(t),f2=sin(t),f3=f1+f2,f4=f1*f2代码: 运行结果:t=0:0.01:4*pi;f1=sin(t);f2= sin(t);f3=f1+f2;f4=f1.*f2;subplot(221);plot(t,f1);title(f1 signal);subplot(222);plot(t,f2);title(f2 signal);subplot(223);plot(t,f3)
2、;title(f1+f2 signal);subplot(224);plot(t,f4);title(f1*f2 signal);2)信号的时移:x(t) = e-0.5tu(t),x1(t) = e-0.5(t+2)u(t+2),x2(t) = e-0.5(t-2)u(t-2)。代码: clear,close all,t = -5:0.01:5;x = exp(-0.5*t).*u(t); % Generate the original signal x(t)x1 = exp(-0.5*(t+2).*u(t+2); % Shift x(t) to the left by 2 second t
3、o get x1(t)x2 = exp(-0.5*(t-2).*u(t-2); % Shift x(t) to the right by 2 second to get x2(t)subplot(311)plot(t,x) % Plot x(t)grid on,title ( x = exp(-0.5*t).*u(t)subplot (312)plot (t,x1) % Plot x1(t)grid on,title ( x1 = exp(-0.5*(t+2).*u(t+2) )subplot (313)plot (t,x2) % Plot x2(t)grid on,title ( x2 =
4、exp(-0.5*(t-2).*u(t-2)xlabel (Time t (sec)function y=u(t)y=(t=0)End程序运行结果:3)信号的时域反褶:m=sin(t);n=sin(-t);程序如下: 运行结果:t=0:0.01:4*pi;m=sin(t); subplot(121);plot(t,m);title(sin(t) signal);subplot(122);plot(-t,m);title(sin(-t) signal);4)信号的时域尺度变换:m=sin(t);n=sin(2t)代码: 运行结果:t=0:0.01:4*pi;k=2*t;m=sin(t);s=si
5、n(k);subplot(121);plot(t,m);title(sin(t) signal);subplot(122);plot(t,s);title(sin(2t) signal);5)卷积的计算:conv调用格式:y= conv (x,h) 求两个有限长序列x,h的卷积注意:conv默认两个信号的时间序列从n=0开始,所以默认y对应的时间序号也从0开始。x(t) = tu(t)-u(t-8)和h(t) =2t u(t)-u(t-8)代码: % Programt = 0:0.01:8;x = t;h =2*t;y =conv(x,h); % Compute the convolution of x(t) and h(t)subplot(221)plot(t,x), grid on, title(Signal x(t), 运行结果:subplot(222)plot(t,h), grid on, title(Signal h(t), subplot(212)t1 = 0:0.01:16; plot(t1,y), grid on, title(Signal y(t)axis(-1 1.1*max(t1) 1.1*min(y) 1.1*max(y)