%% 1
figure(1);
syms t;
f = cos(2*t)*sin(3*t)*heaviside(t);
L = laplace(f);
subplot(2,1,1);
ezplot(f);
subplot(2,1,2);
display(L);
ezplot(L);

%% 2
figure(2);
syms s;
H1 = ((s+1)*(s+4))/(s*(s+2)*(s+3));
f1 = ilaplace(H1);
H2 = (s^3+5*s^2+9*s+7)/(s^2+3*s+2);
f2 = ilaplace(H2);
subplot(2,1,1);
ezplot(f1);
display(f2);
subplot(2,1,2);
display(f2);
ezplot(f2);


%% 3
figure(3);
a = [1, 0, 1];
b = [1,2,-3,3,3,2];
sys = tf(a, b);
pzmap(sys);


%% 4
figure(4);
a = [1, 5];
b = [1, 5, 6];
t = 0:0.01:10;
h = impulse(a, b, t);
subplot(3, 1, 1);
plot(t, h);
title('单位冲激响应');

syms s t;
H = (s+5)/(s^2+5*s+6);
F = laplace(heaviside(t));
Y = H*F;
y = ilaplace(Y);
subplot(3, 1, 2);
fplot(y*heaviside(t));
title('单位阶跃响应');

f = exp(-t)*heaviside(t);
Fs = laplace(f);
Ys = H*Fs;
yts = ilaplace(Ys);
subplot(3, 1, 3);
fplot(yts*heaviside(t));
title('零状态响应');

%% 5
syms t s;
f = (-t+1)*(heaviside(t)-heaviside(t-2))-(heaviside(t-2)-heaviside(t-3));
subplot(2, 1, 1);
ezplot(f);
subplot(2, 1, 2);
F = laplace(f);
H = 1/(s^2+5*s+4);
Y = F*H;
y = ilaplace(Y);
ezplot(y);

