您好,欢迎来到华佗健康网。
搜索
您的当前位置:首页MATLAB信号生成算法

MATLAB信号生成算法

来源:华佗健康网
Matlab 信号生成算法

一、常用信号表示:

1、指数信号: >> t=-2:0.01:2; >> y=exp(t); >> plot(t,y) >> title('指数信号')

2、正弦信号: >> t=0:pi/180:2*pi; >> y=sin(t); >> plot(t,y) >> title('正弦函数')

指数信号8763210-2-1.5-1-0.500.511.52正弦函数10.80.60.40.20-0.2-0.4-0.6-0.8-101234567阶跃信号21.510.50-0.5-1-2-1.5-1-0.500.511.523、阶跃信号: >> t=-2:0.01:2; >> t0=0;

>> y=stepfun(t,t0); >> plot(t,y) >> axis([-2 2 -1 2]) >> title('阶跃信号')

4、 门函数 >> t=-2:0.001:2; >> t1=-0.5; >> t2=0.5;

>> y1=stepfun(t,t1); >> y2=stepfun(t,t2); >> y=y1-y2; >> plot(t,y) >> axis([-2 2 -1 2]) >> title('门函数')

门函数21.510.50-0.5-1-2-1.5-1-0.500.511.52

5、 符号函数 >> t=-2:0.01:2; >> t0=0;

>> y=stepfun(t,t0); >> y1=stepfun(t,t0); >> y=2*y1-1; >> plot(t,y) >> axis([-2 2 -2 2]) >> title('符号函数')

6、斜变信号: >> t=-2:0.01:2; >> t0=0;

>> y1=stepfun(t,t0); >> y=t.*y1; >> plot(t,y)

符号函数21.510.50-0.5-1-1.5-2-2-1.5-1-0.500.511.52斜变函数21.510.50-0.5-1-2-1.5-1-0.500.511.52>> axis([-2 2 -1 2]) >> title('斜变函数')

7、有延迟的斜变信号 >> t=-2:0.01:2; >> t0=1;

>> y1=stepfun(t,t0); >> y=(t-t0).*y1; >> plot(t,y) >> axis([-1 2 -1 1])

>> title('有延迟的斜变信号')

有延迟的斜变信号10.80.60.40.20-0.2-0.4-0.6-0.8-1-1-0.500.511.52

8、三角形脉冲 >> t=-2:0.01:2; >> t0=0; >> t1=1;

>> y1=stepfun(t,t0); >> y2=-stepfun(t,t1); >> y3=y1+y2; >> y=2*t.*y3; >> plot(t,y) >> axis([-1 2 -1 2]) >> title('三角形脉冲')

9、冲激信号: >> t=-1:0.001:1;

>>y=(t==0);

>>plot(t,y)

>> axis([-1 1 -0.5 1.5]) >> title('冲激函数')

三角形脉冲21.510.50-0.5-1-1-0.500.511.52冲激函数1.510.50-0.5-1-0.8-0.6-0.4-0.200.20.40.60.81

二、信号基本运算:

1、相加:

>>t=-2*pi:pi/180:2*pi; >>y1=sin(t); >>subplot(3,1,1); >>plot(t,y1); >>title('sin(t)'); >>y2=sin(0.5*t); >>subplot(3,1,2); >>plot(t,y2); >>title('sin(0.5*t)'); >>y3=sin(t)+sin(0.5*t); >>subplot(3,1,3); >>plot(t,y3);

>>title(‘sin(t)+sin(0.5*t)’);;

2、相乘:

sin(t)10-1-8-6-4-202468sin(0.5*t)10-1-8-6-4-202468sin(t)+sin(0.5*t)20-2-8-6-4-202468sin(t)10-1-8-6-4-202468sin(0.5*t)10-1-8-6-4-202468sin(t)*sin(0.5*t)10-1-8-6-4-202468 >>t=-2*pi:pi/180:2*pi; >>y1=sin(t); >>subplot(3,1,1); >>plot(t,y1); >>title('sin(t)'); >>y2=sin(0.5*t); >>subplot(3,1,2); >>plot(t,y2); >>title('sin(0.5*t)'); >>y3=sin(t).*sin(0.5*t); >>subplot(3,1,3); >>plot(t,y3);

>>title('sin(t)*sin(0.5*t)'); 3、平移:

>> t=-2*pi:pi/180:2*pi; >>subplot(3,1,1); >>y1=sin(t); >>plot(t,y1); >>title('sin(t)'); >>subplot(3,1,2); >>y2=sin(t-pi/2); >>plot(t,y2);

sin(t)10-1-8-6-4-202468sin(t-pi/2)10-1-8-6-4-202468sin(t+pi/2)10-1-8-6-4-202468>>title('sin(t-pi/2)'); >>subplot(3,1,3); >>y2=sin(t+pi/2); >>plot(t,y2); >>title('sin(t+pi/2)');

4、反转和展缩:

(编写m文件:function y=f(t)

y=(t>-1&t<=0).*(t+1)+1*(t>0&t<=1);end)

>>t=-2:0.01:2; >> f1=f(t); >> subplot(3,1,1); >> plot(t,f1);

>> axis([-2 2 -0.5 1.5]); >> title('f(t)'); >> subplot(3,1,2); >> f2=f(-t); >> plot(t,f2);

>> axis([-2 2 -0.5 1.5]) >> title('f(-t)'); >> subplot(3,1,3);

f(t)1.510.50-0.5-2-1.5-1-0.500.511.52f(-t)1.510.50-0.5-2-1.5-1-0.500.511.52f(3*t)1.510.50-0.5-2-1.5-1-0.500.511.52 >> f3=f(3*t); >> plot(t,f3);

>> axis([-2 2 -0.5 1.5]) >>title('f(3*t)');

5、微分和积分:

>> t=0:pi/180:2*pi; >> y=sin(t); >> subplot(3,1,1);

>> plot(t,y); >> title('sin(t)'); >> subplot(3,1,2); >> t1=0:pi/180:2*pi-pi/180; >> t=0:pi/180:2*pi-pi/180; >> z=diff(y); >> plot(t,z); >> title('sin(t)微分'); >> subplot(3,1,3); >>syms t; >>y=sin(t); >> z=int(y,t); >> ezplot(t,z);

sin(t)10-101234567sin(t)微分0.020-0.0201234567x = t, y = -cos(t)0.50-0.5-1-2-1012345678xy

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo0.com 版权所有 湘ICP备2023021991号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务