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
30
31
32
33
34
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
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
30
31
32
33
34
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
+
+
-
-
+
+
+
+
-
-
-
-
-
+
-
-
-
+
+
+
-
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
-
-
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
+
|
#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: sm_r2tex
# Bourne shell script: can_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop 9 Sep 1991, May 1994
# Copyright (c) P.J.Gawthrop, 1991, May 1994, 1996.
# P.J.Gawthrop January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.3 1997/06/13 13:50:11 peterg
# Matrices in amstex format
#
# Revision 1.2 1997/04/18 12:54:00 peterg
# No longer does labels.
#
# Revision 1.1 1996/08/19 15:19:23 peter
# Initial revision
#
###############################################################
# Inform user
echo Creating $1_sm.tex
echo Creating $1_can.tex
# Remove the old log file
rm -f sm_r2tex.log
rm -f can_r2tex.log
# Use reduce to accomplish the transformation
reduce >sm_r2tex.log << EOF
reduce >can_r2tex.log<< EOF
%Read the definitions file
in "$1_def.r";
%Read the constrained-state matrices file
in "$1_sm.r";
%Read the canonical-form matrices file
in "$1_can.r";
%Read the symbolic parameters file
in "$1_sympar.r";
%Read the substitution file
in "$1_subs.r";
%Read the simplification file
in "$1_simp.r";
%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";
OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;
OUT "$1_sm.tex";
OUT "$1_can.tex";
%Write out the state matrices.
write "%state matrices $1";
write "%File: $1.rcm";
%Write out the canonical matrices
write "%Canonical-form matrices $1";
write "%File: $1_can.tex";
write"";
write "%constrained-state matrices";
% Controllable form
MTT_Matrix := MTTA_c$
MTT_Matrix_name := "MTTA_c"$
IF MTTNx>0 THEN
MTT_Matrix_n := MTTNx$
BEGIN
write "% - A matrix";
write "\begin{equation}";
write "MTTA = \begin{pmatrix}";
FOR Row := 1:MTTNx DO
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
MTT_Matrix := MTTB_c$
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
BEGIN
FOR Col := 1:MTTNx DO
BEGIN
Write "{", MTTA(Row,Col), "}";
IF Col<MTTNx THEN Write "&"
END;
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$
MTT_Matrix := MTTC_c$
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
% Observable form
IF Row<MTTNx THEN Write "\cr";
END;
Write "\end{pmatrix}";
write "\end{equation}";
MTT_Matrix := MTTA_o$
MTT_Matrix_name := "MTTA_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
MTT_Matrix := MTTB_o$
MTT_Matrix_name := "MTTB_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$
MTT_Matrix := MTTC_o$
MTT_Matrix_name := "MTTC_o"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% - B matrix";
write "% - Controllability matrix";
write "\begin{equation}";
write "MTTB = \begin{pmatrix}";
FOR Row := 1:MTTNx DO
MTT_Matrix := MTTCon$
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
BEGIN
FOR Col := 1:MTTNu DO
BEGIN
Write "{", MTTB(Row,Col), "}";
IF Col<MTTNu THEN Write "&"
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% -Observability matrix";
MTT_Matrix := MTTObs$
END;
MTT_Matrix_name := "MTTObs"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
IF Row<MTTNx THEN Write "\cr";
END;
Write "\end{pmatrix}";
write "\end{equation}";
write "% -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% - Gain matrix - controller form";
MTT_Matrix := MTTK_c$
MTT_Matrix_name := "MTTK_c"$
MTT_Matrix_n := MTTNu$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% - C matrix";
write "% - Gain matrix - physical form";
write "\begin{equation}";
write "MTTC = \begin{pmatrix}";
FOR Row := 1:MTTNy DO
MTT_Matrix := MTTK$
MTT_Matrix_name := "MTTK"$
BEGIN
FOR Col := 1:MTTNx DO
MTT_Matrix_n := MTTNu$
BEGIN
Write "{", MTTC(Row,Col), "}";
IF Col<MTTNx THEN Write "&"
END;
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
IF Row<MTTNy THEN Write "\cr";
END;
Write "\end{pmatrix}";
write "\end{equation}";
write "% -Observability matrix - Observer form";
MTT_Matrix := MTTObs_o$
MTT_Matrix_name := "MTTObs_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% - Transformation matrix - Observer form";
MTT_Matrix := MTTT_o$
MTT_Matrix_name := "MTTT_o"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
write "% - Observer Gain matrix - observer form";
MTT_Matrix := MTTL_o$
MTT_Matrix_name := "MTTL_o"$
END; %Nx>0
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$
write "% - D matrix";
write "\begin{equation}";
write "MTTD = \begin{pmatrix}";
FOR Row := 1:MTTNy DO
BEGIN
FOR Col := 1:MTTNu DO
BEGIN
Write "{", MTTD(Row,Col), "}";
IF Col<MTTNu THEN Write "&"
END;
write "% - Gain matrix - physical form";
MTT_Matrix := MTTL$
MTT_Matrix_name := "MTTL"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNy$
LaTeX_Matrix()$
% Controllable form
MTT_Matrix := MTTA_comp$
MTT_Matrix_name := "MTTA_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
MTT_Matrix := MTTB_comp$
MTT_Matrix_name := "MTTB_comp"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNu$
LaTeX_Matrix()$
MTT_Matrix := MTTC_comp$
MTT_Matrix_name := "MTTC_comp"$
MTT_Matrix_n := MTTNy$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$
IF Row<MTTNy THEN Write "\cr";
END;
Write "\end{pmatrix}";
write "\begin{equation}";
write "MTTur = {", MTTu_r, "}";
write "\end{equation}";
SHUT "$1_sm.tex";
SHUT "$1_can.tex";
quit;
EOF
|