11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# Copyright (c) P.J.Gawthrop, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.13 1998/05/14 08:05:10 peterg
## Put back under RCS
##
## Revision 1.12 1998/02/25 18:02:39 peterg
## Removed the argument passing stuff .
## Replaced by the simpar.m method.
##
|
>
>
>
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# Copyright (c) P.J.Gawthrop, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14 1998/05/19 19:48:02 peterg
## Read the simpar file now.
##
## Revision 1.13 1998/05/14 08:05:10 peterg
## Put back under RCS
##
## Revision 1.12 1998/02/25 18:02:39 peterg
## Removed the argument passing stuff .
## Replaced by the simpar.m method.
##
|
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
|
METHOD = 'Euler'
end;
if exist('x')==0
x = zeros(nx,1);
end;
[n,m]=size(T);
if m>n
T=T';
end;
method = tolower(METHOD)
if nx>0
if strcmp(method,'lsode')
X = lsode('$1_ode', x, T);
elseif strcmp(method,'euler')
%Euler integration
X=[];
dt = (T(2)-T(1))/STEPFACTOR;
for t=T'
X = [X; x'];
ts = t;
for i=1:STEPFACTOR
dx = $1_ode(x,ts);
ts = ts + dt;
x = x + dx*dt;
end;
end;
else
error('Method %s not available here', METHOD);
return;
end;
write_matrix([T,X], '$1_odes');
else
X = zeros(size(T));
end;
if ny>0 % compute y and print it
i = 0; Y=[];
for t=T'
i = i+1;
y = $1_odeo(X(i,:),t);
Y = [Y; y'];
end;
write_matrix([T,Y], '$1_odeso');
end;
|
>
>
>
|
>
|
>
>
|
|
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
|
METHOD = 'Euler'
end;
if exist('x')==0
x = zeros(nx,1);
end;
% xx is the composite vector containing x and the internal inputs.
xx = [x; zeros(nyz,1)];
[n,m]=size(T);
if m>n
T=T';
end;
method = tolower(METHOD)
if nx>0
if strcmp(method,'lsode')
X = lsode('$1_ode', x, T);
elseif strcmp(method,'euler')
%Euler integration
X=[];
dt = (T(2)-T(1))/STEPFACTOR;
for t=T'
X = [X; xx'];
ts = t;
for i=1:STEPFACTOR
x = xx(1:nx);
xx = $1_ode(xx,ts);
ts = ts + dt;
dx = xx(1:nx);
x = x + dx*dt;
xx(1:nx) = x;
end;
end;
else
error('Method %s not available here', METHOD);
return;
end;
write_matrix([T,X], '$1_odes');
else
X = zeros(size(T));
end;
if ny>0 % compute y and print it
i = 0; Y=[];
for t=T'
i = i+1, X(i,:)
y = $1_odeo(X(i,:),t);
Y = [Y; y'];
end;
write_matrix([T,Y], '$1_odeso');
end;
|