Overview
Comment:Only compute matrix exponential once.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 456ffafe03e4333df7f784c8044b2419215d02e87f3fc933d931790133ca8d93
User & Date: gawthrop@users.sourceforge.net on 1996-10-27 10:39:04
Other Links: branch diff | manifest | tags
Context
1996-10-31
20:48:41
Revised html generation.
Stopped deletion of rep.txt file.
check-in: fa0dfdeafb user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1996-10-27
10:39:04
Only compute matrix exponential once. check-in: 456ffafe03 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1996-10-21
12:34:47
Initial revision check-in: 4bccf60e71 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/sm2sr.m from [74f8e1e5b8] to [3cfd117635].

1
2
3
4
5
6
7
8
9
10
11
12



13
14
15
16
17
18
19
function [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% Constrained-state matrix to impulse response.
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$



% %% Revision 1.1  1996/08/19 15:34:29  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);












>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% Constrained-state matrix to impulse response.
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2  1996/09/10  16:48:21  peter
% %% Changed ar counts in default settings.
% %%
% %% Revision 1.1  1996/08/19 15:34:29  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
36
37
38
39
40
41
42



43


44
45
46
47
48

49
50
51
52
53
54
55



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;







>
>
>

>
>



<

>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63



one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);

dt = T(2)-T(1);% Assumes fixed interval
expAdt = expm(A*dt); % Compute matrix exponential
i = 0;
expAt = one;

for t = T'
  i=i+1;
  if Nx>0

    x = ( A\(expAt-one) )*B*u0 + expAt*x0;
    expAt = expAt+expAdt;
    X(i,:) = x';
    if Ny>0
      y = C*x + D*u0;
      Y(i,:) = y';
    end;
  elseif Ny>0
    y = D*u0;


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]