Overview
Comment:Use exact solution - slow but accurate
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 8f3d43426612ec50ba6beb8cc98e1827dfd3901f9f079ac26bc9928ffa15fbba
User & Date: gawthrop@users.sourceforge.net on 2005-03-04 09:19:53
Other Links: branch diff | manifest | tags
Context
2005-03-15
12:04:15
New labg.fig rep - pretty LaTeX figures. check-in: 8741109857 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2005-03-04
09:19:53
Use exact solution - slow but accurate check-in: 8f3d434266 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2005-02-21
17:39:25
Fixed vector junctions. check-in: d148584101 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/sm2ir.m from [cdcd279f9b] to [4fd52f72ba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



20
21
22
23
24
25
26
function [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% sm2ir - Constrained-state matrix to impulse response.
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sm2ir
% [Y,X] = sm2ir(A,B,C,D,T,u0,x0);
% A,B,C,D,E - (constrained) state matrices
% T vector of time points
% u0 input gain vector: u = u0*unit impulse.


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



% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if max(max(abs(D)))~=0

|

















>
>
>







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


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1996/12/05 10:17:34  peterg
% %% Put in version control history.
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[Ny,Nu] = size(D);
[Ny,Nx] = size(C);

if max(max(abs(D)))~=0
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70
71
72
73
74

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
expAt = one;
i = 0;
x = (B*u0+x0);
for t = T'
  i=i+1;
  if Nx>0
    % expAt = expm(A*t);
    x = expAdt*x;

    X(i,:) = x';
    if Ny>0
      y = C*x;
      Y(i,:) = y';
    end;
  end;
end;













|
|





|
|
>













49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

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
##expAt = one;
i = 0;
x = (B*u0+x0);
for t = T'
  i=i+1;
  if Nx>0
    ##expAt = expm(A*t);
    ##x = expAdt*x;
     x = expm(A*t)*(B*u0+x0);
    X(i,:) = x';
    if Ny>0
      y = C*x;
      Y(i,:) = y';
    end;
  end;
end;







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