Differences From Artifact [3cfd117635]:

To Artifact [aedb773097]:


1







2
3
4
5
6
7
8
9
10
11
12



13
14
15
16
17
18
19
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

+
+
+
+
+
+
+

-









+
+
+







function [Y,X] = sm2sr(A,B,C,D,T,u0,x0);
% sm2sr - Constrained-state matrix to step response.
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  sm2sr
% [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.3  1996/10/27  10:39:04  peterg
% %% Only compute matrix exponential once.
% %%
% %% 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
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36
37
38
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
64
65
66

























67


68


69







70
71
72
44
45
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+

+
+

+
+
+
+
+
+
+



if M>N
  T = T';
  N = M;
end;



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;
    Y(i,:) = y';
  end;
end;
% $$$ 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;
% $$$     Y(i,:) = y';
% $$$   end;
% $$$ end;

% Compute the impulse response
[Y,X] = sm2ir(A,B,C,D,T,u0,x0);

% Assume fixed sample interval
dT = T(2)-T(1);

% Do an Euler integration on it
 Y = mtt_euler(Y,dT);
 
 if nargout>1
   X = mtt_euler(X,dT);
 end;
 




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