This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/Matlab/lab1.m
2022-04-26 14:51:03 +08:00

55 lines
755 B
Matlab

figure(1);
syms x;
t=-5:0.0001:5;
fx=heaviside(x+2)-heaviside(x-2);
ezplot(fx,[-5,5]);
figure(2);
fy=heaviside(x+0.2)-heaviside(x-0.2);
ezplot(fy,[-5,5]);
figure(3);
fz=heaviside(x+0.1)-heaviside(x-0.1);
ezplot(fz,[-5,5]);
figure(4);
subplot(2,1,1);
fa=5*cos(12*pi*t)+6*cos(18*pi*t);
plot(t,fa);
subplot(2,1,2);
xcorr1=autocorr(fa,t);
plot(corr1);
figure(5);
fb=(cos(2*pi*t)).*(cos(2*pi*t));
plot(t,fb);
figure(6);
t = 0:0.1:10;
b1=[1,5,6];
a1=[1,5];
sys=tf(a1,b1);
y1=step(sys,t);
a2=[1,5];
b2=[1,2,5];
sys=tf(a2,b2);
y2=step(sys,t);
a3=[1.5];
b3=[1,2,1];
sys=tf(a3,b3);
y3=step(sys,t);
plot(t,y1,t,y2,'--',t,y3,'+');
figure(7);
sys=tf([1,2],[1,3,2]);
y=impulse(sys,t);
plot(t,y);
f=cos(t);
sys=tf([-1,2],[1,3,2]);
y=lsim(sys,f,t);
plot(t,f);