实验二 连续时间信号在Matlab中的运算
一、实验目的
1、学会运用Matlab进行连续时间信号的时移、反褶和尺度变换;
2、学会运用Matlab进行连续时间信号微分、积分运算;
3、学会运用Matlab进行连续时间信号相加、相乘运算;
4、学会运用Matlab进行连续时间信号卷积运算。
二、实验内容
1、已知信号的波形(课本P11例题),画出的波形图。
% 实验二 连续时间信号Matlab表示
%参考:基于Matlab的信号与系统试验指导
% 参数:
% t: 时间变量
% pi:matlab提供常数,3.1416
1、已知信号的波形(课本P11例题),画出的波形图。
clear all;close all;clc
t=-5:0.01:5;
y1=2*exp(-(t/4).^2);
y2=2*exp(-((t-2)/4).^2);
y3=2*exp(-(3*t/4).^2);
y4=2*exp(-(-t/4).^2);
subplot(2,2,1);plot(t,y1);
axis([-6,6,0,3]);title('f1(t)');
grid on;
subplot(2,2,2);plot(t,y2);
axis([-6,6,0,3]);title('f2(t)');
grid on;
subplot(2,2,3);plot(t,y3);
axis([-6,6,0,3]);title('f3(t)');
grid on;
subplot(2,2,4);plot(t,y4);
axis([-6,6,0,3]);title('f4(t)');
grid on;
2、使用微分命令求关于变量x的一阶导数;使用积分命令计算不定积分 clear all;close all;clc
syms x;
y=x*sin(x)*log(x);
dy=diff(y,'x',1)
z=x^5-2*x*x+sqrt(x)/2;
lz=int(z,'x')
,定积分。
w=x*exp(x)/[(1+x)^2];
lw=int(w,'x',0,1)
dy =
sin(x)*log(x)+x*cos(x)*log(x)+sin(x)
lz =
1/6*x^6-2/3*x^3+1/3*x^(3/2)
lw =
1/2*exp(1)-1
3、已知,使用命令画出两信号和及两信号乘积的波形图。其中,
clc;clear all;
t=-2:0.01:2;
y1=sin(2*pi*t);
y2=sin(8*2*pi*t);
y3=sin(2*pi*t).*sin(8*2*pi*t);
plot(t,y1,t,y2,t,y3);
axis([-2 2 -1 1]);
xlabel('t'),ylabel('y');
grid on;
4、
function f=uCT(t)
f=(t>=0);
clear all;close all;clc;
t=-1:0.01:4;dt=0.01;
f1=uCT(t)-uCT(t-2);
f2=uCT(t)+uCT(t-1)-uCT(t-2);
f=conv(f1,f2)*dt;
n=length(f);tt=(0:n-1)*dt-2;
plot(tt,f);grid on;
axis([-2 7 -1 4]);
title('f(t)=f1(t)*f2(t)');xlabel('t');
实验思考:
很多的函数都记不太清它的语句格式了,出错很多。问题很好的工具。
确实是解决信号与系统Matlab