% Problem 3.28

disp('Problem 3.28')
disp(' ')

% System model
A=[-0.58 0 0 -0.27 0 0.2 0;
    0 -1 0 0 0 1 0;
    0 0 -5 2.1 0 0 0;
    0 0 0 0 337 0 0;
   -0.14 0 0.14 -0.2 -0.28 0 0;
    0 0 0 0 0 0.08 2;
   -17.2 66.7 -11.6 40.9 0 -66.7 -16.7];

B=[0; 0; 0; 0; 0; 0; 1];

C=[1 zeros(1,6)];

D=0;

x0=[1; 1; 1; 1; 1; 1; 1];

disp('Problem 3.28')

% 3.28(a) - Eigenvalues, eigenvectors and similarity transform
l=eig(A);
[V,Diag]=eig(A);
disp(' ')
disp('(a) - Eigenvalues')
l
disp('(a)  - Eigenvectors')
for i=1:7,
  vec=V(:,i)
end
disp(' ')
disp('(a)  - Similarity transformation')
Diag
V

% 3.28(b) - Discretization, Sampling time T=1sec
T=1

% Discrete-time system
[Ad,Bd]=c2d(A,B,T);
disp(' ')
disp('(b) - Discrete-time system')
Ad

% 3.28(c) - Initial condition response
dinitial(Ad,Bd,C,D,x0,11)
grid
ylabel('output')
xlabel('no. of samples')

