10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.6 1997/02/24 14:43:21 peterg
# Now ignores parameters that are numerical.
#
## Revision 1.5 1996/09/12 18:34:44 peter
## Back under rcs.
##
# Revision 1.4 1996/08/24 14:12:26 peter
|
>
>
>
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7 1998/06/23 19:18:33 peterg
## Added optional state argument.
##
# Revision 1.6 1997/02/24 14:43:21 peterg
# Now ignores parameters that are numerical.
#
## Revision 1.5 1996/09/12 18:34:44 peter
## Back under rcs.
##
# Revision 1.4 1996/08/24 14:12:26 peter
|
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
|
# Inform user
echo Creating $1_sm.m
# Remove the old log file
rm -f sm_r2m.log
# Use reduce to accomplish the transformation
reduce >sm_r2m.log << EOF
%Read in the definitions file
IN "$1_def.r";
%Read the reduce state-space A,B,C and D matrices file
IN "$1_sm.r";
%Set up the number of argument variables to zero in case the user has forgotten
MTTNVar := 0;
%Read in the parameter file
IN "$1_sympar.r";
OUT "$1_sm.m";
%Headings - Matlab style
%(Note. The ;; are deleted by for2mat)
write "function [A,B,C,D] = $1_sm(x);;";
write "%function [A,B,C,D] = $1_sm(x);;";
write "%Linearised state matrices for system $1";
write "%File $1_sm.m";
write "%Generated by MTT";
IF MTTNvar>0 THEN
BEGIN
write "% Set the parameters";
write "global ...;;";
FOR i := 1:MTTNvar DO
BEGIN
IF numberp(MTTVar(i,1))
THEN
BEGIN
% Do nowt
END
ELSE
BEGIN
write MTTVar(i,1), " ...";
END;
END;
write " ";
END;
write "% Set the state (if given as an argument)";
write "if nargin>0";
FOR i := 1:MTTNx DO
write " mttx
", i, " = x(", i, ");";
write "end;";
write "";
%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$
write "MTTA = zeros(", MTTNx, ",", MTTNx, ");";
write "MTTB = zeros(", MTTNx, ",", MTTNu, ");";
write "MTTC = zeros(", MTTNy, ",", MTTNx, ");";
write "MTTD = zeros(", MTTNy, ",", MTTNu, ");";
ON NERO; % Suppress zero elements.
MTTA := MTTA;
MTTB := MTTB;
MTTC := MTTC;
MTTD := MTTD;
OFF FORT;
write "";
SHUT "$1_sm.m";
|
>
>
>
|
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
>
>
>
>
|
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
|
# Inform user
echo Creating $1_sm.m
# Remove the old log file
rm -f sm_r2m.log
#Header
lang_header $1 sm m '' '[mtta,mttb,mttc,mttd]' >$1_sm.m
# Use reduce to accomplish the transformation
$SYMBOLIC >sm_r2m.log << EOF
%Read in the definitions file
IN "$1_def.r";
%Read the reduce state-space A,B,C and D matrices file
IN "$1_sm.r";
%Read in the parameter file
IN "$1_sympar.r";
OUT "$1_sm.m1";
%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 100$
OFF period$
write "mtta = zeros(", MTTNx, ",", MTTNx, ");";
write "mttb = zeros(", MTTNx, ",", MTTNu, ");";
write "mttc = zeros(", MTTNy, ",", MTTNx, ");";
write "mttd = zeros(", MTTNy, ",", MTTNu, ");";
ON NERO; % Suppress zero elements.
mtta := mtta;
mttb := mttb;
mttc := mttc;
mttd := mttd;
OFF FORT;
write "";
SHUT "$1_sm.m1";
EOF
cat $1_sm.m1 >> $1_sm.m
#rm -f $1_sm.m1
|