% ALEXANDROS RASOULIS, 2015010123
syms s 

% ANALOGIKOS-OLOKLIROTIKOS ELEGKTIS

K=3+1;
T=(3+1)/2;
Kc=1*(3+1);
Gc=Kc*(1+(1/T*s));
Gv=1;
Gm=1;
Gp=K/(T*s+1);
Ysp=1/s

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

Total_Time=40;
t=0:0.1:Total_Time;
y=subs(y,t);
y=double(y);
u=subs(u,t);
u=double(u);
ysp=ilaplace(Ysp);
ysp=subs(ysp,t);
ysp=double(ysp);

figure(1);plot(t,y,t,ysp,'--',t,u,'o');axis([0 max(t) 0 max(y)*1.2]);xlabel('time');ylabel('y(t) & u(t)')