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.3 1998/05/19 19:27:04 peterg
## Zapped all the parameter stuff
##
## Revision 1.2 1996/09/13 19:40:51 peter
## Fixed problem with default paramaters.
##
## Revision 1.1 1996/09/12 19:26:57 peter
|
>
>
>
|
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.4 2000/10/17 11:07:59 peterg
## *** empty log message ***
##
## Revision 1.3 1998/05/19 19:27:04 peterg
## Zapped all the parameter stuff
##
## Revision 1.2 1996/09/13 19:40:51 peter
## Fixed problem with default paramaters.
##
## Revision 1.1 1996/09/12 19:26:57 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
|
## Initial revision
##
###############################################################
echo Creating $1_odess.m
rm -f ode2odess_m.log
$MATRIX << EOF > ode2odess_m.log 2>mtt_error.txt
%Read in parameters
$1_numpar;
[nx,ny,nu,nz,nyz] = $1_def;
%Read in simulation parameters
$1_simpar;
T = [0:DT:LAST];
t=0; %Just in case it appears in the parameter list.
%Defaults
if exist('T')==0
T=[0:0.1:1]
end;
if exist('x0')==0
x0 = zeros(nx,1);
end;
[n,m]=size(T);
if m>n
T=T';
end;
global t;
function dx=f(x)
global t
dx = $1_ode(x,t);
endfunction;
i=0;
for t=T'
i=i+1;
x(i,:) = fsolve('f',x0)';
end;
i=0;
for t=T'
i=i+1;
y(i,:) = $1_odeo(x(i,:),t)';
end;
write_matrix([T,x], '$1_odess');
write_matrix([T,y], '$1_odesso');
EOF
|
>
>
>
>
|
<
<
<
|
|
|
>
>
|
>
<
>
>
>
|
<
|
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
|
## Initial revision
##
###############################################################
echo Creating $1_odess.m
rm -f ode2odess_m.log
Nx=`mtt_getsize $1 x` # States
Nxx=`mtt_getsize $1 xx` # States x States
Nu=`mtt_getsize $1 u` # Inputs
Ny=`mtt_getsize $1 y` # Inputs
$MATRIX << EOF > ode2odess_m.log 2>mtt_error.txt
%Read in parameters
par = $1_numpar;
%Read in simulation parameters
simpar=$1_simpar;
T = [0:simpar.dt:simpar.last];
t=0; %Just in case it appears in the parameter list.
%Defaults
if exist('T')==0
T=[0:0.1:1]
end;
if exist('x0')==0
x0 = zeros($Nx,1);
end;
[n,m]=size(T);
if m>n
T=T';
end;
global t;
function dx=f(x)
global t
par = $1_numpar;
u = $1_input(x,zeros($Ny,1),t,par);
dx = $1_ode(x,u,t,par);;
endfunction;
i=0;
x = x0;
for t=T'
u = $1_input(x,zeros($Ny,1),t,par);
y(i) = $1_odeo(x,u,t,par)';
mtt_write(t,x,y,$Nx,$Ny); # Write it out
x = fsolve('f',x)';
end;
i=0;
for t=T'
i=i+1;
end;
write_matrix([T,x], '$1_odess');
write_matrix([T,y], '$1_odesso');
EOF
|