%University College of Southeast Norway
%Courses IA3112 og EK3114
%Finn Haugen (finn.haugen@usn.no)
%30 Oct 2017

%----------------------------------------------

s=tf('s')
K=1%Gain
T=1%Time constant
tau=0%Time delay
H1=(K/(T*s+1))*exp(-tau*s)
figure(1)
bode(H1)
grid

dt=0.001;
t_start=0;
t_stop=50;
t=[t_start:dt:t_stop]';
w=1 %rad/s
A=1;
u=A*sin(w*t);%Input signal
y=lsim(H1,u,t);%Response in output signal
figure(2)
plot(t,u,'b',t,y,'r')
title('Sine input (u, blue) and response (y, red) of H1(s)')
xlabel('t [s]')
grid
