% Problem 3.3
% Model of the system
disp(' ')
disp('Problem 3.3: System model')
A = [ 0  1;
     -1  0]
B = [ 0; 1]
C = [0 1]
D=0

disp(' ')
disp('3,3 - Zeros and poles')
[z,p,k]=ss2zp(A,B,C,D,1)

disp(' ')
disp('3.2 - Transfer function:')
[num,den]=ss2tf(A,B,C,D,1);
for i=length(num):-1:1,
   if num(i)<1.e-10
      num(i)=0;
   end
end
printsys(num,den,'s')

% 3.3(c) Unit step response
u=ones(101,1);
t=0:0.1:10;
[y_ss,x]=lsim(num,den,u,t);
y_tr=cos(t);
y=y_ss'+y_tr;
plot(t,y)
grid
ylabel('Output y')
xlabel('time [s]')