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
|
#cat << EOF > $1_ode2odes.m
# Program $1_ode2odes
#EOF
# Do the globals
#sympar2global_txt2m $1 >> $1_ode2odes.m
lang_header $1 ode2odes m 'x,U,par,simpar' '[Y,X,t]' > $1_ode2odes.m
cat >> $1_ode2odes.m <<EOF
global MTT_data;
if nargin<1
x = $1_state;
endif
if nargin<2
U = $1_input(0);
endif
if nargin<3
par = $1_numpar;
endif
if nargin<4
simpar = $1_simpar;
endif
## Initialise
t = 0.0;
ilast = round(simpar.last/simpar.dt); # Total number of steps
[u] = zero_input(1); # Zero the input
for it = 1:ilast #Integration loop
[y] = $1_cseo(x,u,t,par);# Output
[u] = $1_input(t,x,y,U); # Input
if (t>=simpar.first)
mtt_write(t,x,y,$Nx,$Ny); # Write it out
endif
[dx] = $1_cse(x,u,t,par); # State derivative
[AA] = $1_smxa(x,u,simpar.dt,par); # (I-Adt) and (I-Adt)x
[AAx] = $1_smxax(x,u,simpar.dt,par); # (I-Adt) and (I-Adt)x
[open] = $1_switchopen(x); # Open switches
[x] = mtt_implicit(x,dx,AA,AAx,simpar.dt,$Nx,open); # Implicit update
t = t + simpar.dt;
endfor; # Integration loop
t = MTT_data(:,1);
Y = MTT_data(:,2);
X = MTT_data(:,4);
|
|
|
>
<
<
<
>
|
>
|
|
|
|
|
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
|
#cat << EOF > $1_ode2odes.m
# Program $1_ode2odes
#EOF
# Do the globals
#sympar2global_txt2m $1 >> $1_ode2odes.m
lang_header $1 ode2odes m 'x,par,simpar' '[Y,X,t]' > $1_ode2odes.m
cat >> $1_ode2odes.m <<EOF
global MTT_data;
if nargin<1
x = $1_state;
[x] = mtt_state_update(x);
endif
if nargin<2
par = $1_numpar;
[par] = mtt_numpar_update(par);
endif
if nargin<3
simpar = $1_simpar;
[simpar.dt] = mtt_simpar_update;
endif
## Initialise
t = 0.0;
ilast = round(simpar.last/simpar.dt)+1; # Total number of steps
[u] = zero_input(1); # Zero the input
for it = 1:ilast #Integration loop
[y] = $1_cseo(x,u,t,par);# Output
[u] = $1_input(t,x,y); # Input
if (t>=simpar.first)
mtt_write(t,x,y,$Nx,$Ny); # Write it out
endif
[dx] = $1_cse(x,u,t,par); # State derivative
[AA] = $1_smxa(x,u,simpar.dt,par); # (I-Adt) and (I-Adt)x
[AAx] = $1_smxax(x,u,simpar.dt,par); # (I-Adt) and (I-Adt)x
[open_switches] = $1_switchopen(x); # Open switches
[x] = mtt_implicit(x,dx,AA,AAx,simpar.dt,$Nx,open_switches); # Implicit update
t = t + simpar.dt;
endfor; # Integration loop
t = MTT_data(:,1);
Y = MTT_data(:,2);
X = MTT_data(:,4);
|