1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
function sr = dm2sr(A,B,C,D,E,T,u0,x0);
% sr = dm2sr(A,B,C,D,E,T);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3 1996/08/11 19:33:24 peter
% %% Replaced exp by expm - whoops!
% %%
% %% Revision 1.2 1996/08/11 10:37:40 peter
% %% Corrected mistake in step-response calculation.
% %%
% %% Revision 1.1 1996/08/11 09:42:40 peter
|
|
|
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
function [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4 1996/08/15 08:34:08 peter
% %% Added step gain (u0) and initial condition (x0)
% %%
% %% Revision 1.3 1996/08/11 19:33:24 peter
% %% Replaced exp by expm - whoops!
% %%
% %% Revision 1.2 1996/08/11 10:37:40 peter
% %% Corrected mistake in step-response calculation.
% %%
% %% Revision 1.1 1996/08/11 09:42:40 peter
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
if M>N
T = T';
N = M;
end;
one = eye(Nx);
sr = zeros(N,Ny);
i = 0;
for t = T'
i=i+1;
expAt = expm(A*t);
SR = C*( ( A\(expAt-one) )*B*u0 + expAt*x0) + D*u0;
sr(i,:) =SR';
end;
|
|
>
>
|
|
|
>
>
>
|
>
>
>
>
>
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
if M>N
T = T';
N = M;
end;
one = eye(Nx);
Y = zeros(N,Ny);
X = zeros(N,Nx);
i = 0;
for t = T'
i=i+1;
if Nx>0
expAt = expm(A*t);
x = ( A\(expAt-one) )*B*u0 + expAt*x0;
X(i,:) = x';
if Ny>0
y = C*x + D*u0;
Y(i,:) = y';
end;
elseif Ny>0
y = D*u0;
Y(i,:) = y';
end;
end;
|