clc
clear

syms s

Gp=1/(2*s+1);
Gm=1/(s+1);
Go=2/(2*s+1);
Gv=1/(3*s+1);
Ysp=24/s;
To=24;
Kc=10;
Gc=Kc;

Y=Gp*Gv*Gc*Ysp/(1+Gp*Gv*Gc*Gm)+Go*To/(1+Gp*Gv*Gc*Gm);
y=ilaplace(Y)
U=(Gc*Gv*Ysp)/(1+Gp*Gv*Gm*Gc)-(Go*Gv*Gm*Gc*To)/(1+Gp*Gv*Gm*Gc);
u=ilaplace(U)

Total_Time=100;
t=0:0.5:Total_Time;
y=vpa(y);
y=subs(y,t);
y=double(y);
u=vpa(u);
u=subs(u,t);
u=double(u);
ysp1=ilaplace(Ysp);
ysp1=subs(ysp1,t);
ysp1=double(ysp1);

figure(1);plot(t,y,t,ysp1,'--');axis([0 max(t) 5 40]);xlabel('time, min');ylabel('y(t)')


figure(2);plot(t,u);axis([0 max(t) -15 50]);xlabel('time, min');ylabel('u(t)')
