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
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3 2000/10/11 08:59:15 peterg
## Added csex rep
##
## Revision 1.2 2000/10/11 08:01:42 peterg
## Added noglobal fudge
##
## Revision 1.1 2000/10/10 21:02:27 peterg
## Initial revision
##
###############################################################
# Arguments
system=$1
rep=$2
language=$3
args=$4
output=$5
extras=$6
# Find system constants
Nx=`mtt_getsize $system x` # States
Nxx=`mtt_getsize $system xx` # States x States
Nu=`mtt_getsize $system u` # Inputs
Ny=`mtt_getsize $system y` # Outputs
Nyz=`mtt_getsize $system yz` # Zero outputs
Npar=`wc -l $system\_sympar.txt | awk '{print $1}'`
# Representation-specific stuff
case $rep in
cse)
states=yes;
inputs=yes;
parameters=yes;
;;
csex)
states=yes;
inputs=yes;
parameters=yes;
;;
cseo)
states=yes;
inputs=yes;
parameters=yes;
;;
ode)
states=yes;
inputs=yes;
parameters=yes;
;;
numpar)
states=no;
inputs=no;
parameters=no;
;;
odeo)
states=yes;
inputs=yes;
parameters=yes;
;;
sm)
states=no;
inputs=no;
parameters=yes;
;;
*)
esac
# Lanuage specific stuff
case $language in
m)
modeline='% -*-octave-*- Put Emacs into octave-mode%';
ext='m';
Lc='##';
Rc='';
Lb='(';
Rb=')';
function="function"
declaration="[$output] = $1_$rep($args);"
noglobals=true; # Fudge to make mtt_m2p work
;;
*)
echo Language $language not supported - sorry; exit 1
esac
# Header information
cat<<EOF
$modeline
$function $declaration
$Lc $declaration
$Lc System $system, representation $rep, language $language; $Rc
$Lc File $1_$rep.$ext; $Rc
$Lc Generated by MTT on `date`; $Rc
EOF
if [ -n "$noglobals" ]; then
cat<<EOF
## Horrible fudge to make mtt_m2p work
global ...
mtt_no_globals ;
EOF
fi
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF
$Lc Parameters
EOF
sympar2par_txt2m $1
fi
# States
if [ "$states" = "yes" ]; then
cat <<EOF
$Lc States
EOF
N=`n2m 1 $Nx`
for i in $N; do
echo ' mttx'$i' = mttx('$i');'
done
fi
# Inputs
if [ "$inputs" = "yes" ]; then
cat <<EOF
$Lc Inputs
EOF
N=`n2m 1 $Nu`
for i in $N; do
echo ' mttu'$i' = mttu('$i');'
done
fi
|
>
>
>
|
|
|
>
>
>
>
>
>
>
>
<
>
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
|
|
>
<
>
>
>
>
|
|
|
>
|
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
194
195
196
197
198
199
200
201
202
203
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4 2000/10/14 06:49:31 peterg
## Make parameter listing representation dependent
##
## Revision 1.3 2000/10/11 08:59:15 peterg
## Added csex rep
##
## Revision 1.2 2000/10/11 08:01:42 peterg
## Added noglobal fudge
##
## Revision 1.1 2000/10/10 21:02:27 peterg
## Initial revision
##
###############################################################
# Arguments
system=$1
rep=$2
language=$3
#args=$4
#output=$5
#extras=$6
# Find system constants
Nx=`mtt_getsize $system x` # States
Nxx=`mtt_getsize $system xx` # States x States
Nu=`mtt_getsize $system u` # Inputs
Ny=`mtt_getsize $system y` # Outputs
Nyz=`mtt_getsize $system yz` # Zero outputs
Npar=`wc -l $system\_sympar.txt | awk '{print $1}'`
# Representation-specific stuff
eqnargs='mttx,mttu,mttt,mttpar'
case $rep in
cse)
states=yes;
inputs=yes;
parameters=yes;
output='mttedx,mtte'
args=$eqnargs
;;
csex)
states=yes;
inputs=yes;
parameters=yes;
output=mttedx
args=$eqnargs
;;
cseo)
states=yes;
inputs=yes;
parameters=yes;
output=mtty
args=$eqnargs
;;
input)
states=no;
inputs=no;
parameters=no;
output=mttu
args='x,y,t,par'
;;
numpar)
states=no;
inputs=no;
parameters=no;
output='mttpar'
;;
ode)
states=yes;
inputs=yes;
parameters=yes;
output='mttdx'
args=$eqnargs
;;
odeo)
states=yes;
inputs=yes;
parameters=yes;
output='mtty'
args=$eqnargs
;;
simpar)
states=no;
inputs=no;
parameters=no;
output=mttsimpar
;;
sm)
states=no;
inputs=no;
parameters=yes;
output='mtta,mttb,mttc,mttd'
args=mttpar
;;
state)
states=no;
inputs=no;
parameters=yes;
output=mttx
args=mttpar
;;
*)
echo Representation $rep not supported - sorry; exit 1
esac
## Sort out parentheses
if [ -n "$args" ]; then
Args='('$args')'
fi
if [ -n "$output" ]; then
Output="[$output] = "
fi
# Lanuage specific stuff
case $language in
m)
modeline='## -*-octave-*- Put Emacs into octave-mode ##';
ext='m';
Lc='##';
Rc='';
Lb='(';
Rb=')';
function="function"
declaration="$Output$1_$rep$Args;"
noglobals=true; # Fudge to make mtt_m2p work
start='## BEGIN Code'
;;
*)
echo Language $language not supported - sorry; exit 1
esac
# Header information
cat<<EOF
$function $declaration
$Lc $declaration
$Lc System $system, representation $rep, language $language; $Rc
$Lc File $1_$rep.$ext; $Rc
$Lc Generated by MTT on `date`; $Rc
EOF
if [ -n "$noglobals" ]; then
cat<<EOF
## Horrible fudge to make mtt_m2p work
global ...
mtt_no_globals ;
EOF
fi
# Mark start of code
echo
echo $start
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF
$Lc Parameters $Rc
EOF
sympar2par_txt2m $1
fi
# States
if [ "$states" = "yes" ]; then
cat <<EOF
$Lc States $Rc
EOF
N=`n2m 1 $Nx`
for i in $N; do
echo ' mttx'$i' = mttx('$i');'
done
fi
# Inputs
if [ "$inputs" = "yes" ]; then
cat <<EOF
$Lc Inputs $Rc
EOF
N=`n2m 1 $Nu`
for i in $N; do
echo ' mttu'$i' = mttu('$i');'
done
fi
|