% Solution to Excercise 1b, point 9).
clear all

Ac=[0 1;-8 -6]; Bc=[0;1]; Dc=[1 0]; % Matrices in continuous model

Dt=0.1;                    % Sampling interval
A=expm(Ac*Dt);             % Transition matrix in discrete time model
B=inv(Ac)*(A-eye(2))*Bc;   % Input matrix in discrete time model

t=0:0.1:5;                 % Time interval to simulate
N=length(t)                % 

x=[0;0];
u=1;
for k=1:N
    y=Dc*x
    
    Y(k,1)=y;
    X(k,1:2)=x';
    
    x=A*x+B*u
end

plot(t,Y), grid
xlabel('Time  0 \leq t \leq 4')
title('Response in the output y(t) after unit step response in u(t)')