ADDED mttroot/mtt/bin/trans/ode2odess_m2dat2 Index: mttroot/mtt/bin/trans/ode2odess_m2dat2 ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/ode2odess_m2dat2 @@ -0,0 +1,105 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: ode2odess_m + +# Transforms descriptor matrix rep to step response + +# 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 +## Initial revision +## +## Revision 1.4 1996/08/16 13:04:46 peter +## Fixed problem with more than one output (y vector). +## +## Revision 1.3 1996/08/16 06:36:03 peter +## Removed u from default arg list. +## +## Revision 1.2 1996/08/15 16:24:43 peter +## Uses T in place of t to avoid name clash within function. +## +## Revision 1.1 1996/08/15 11:56:38 peter +## Initial revision +## +############################################################### + +echo Creating $1_odess.dat2 +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_m2dat2.log 2>mtt_error.txt + + global MTT_data # Where mtt_write puts its stuff + %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; + +x = x0; +for t=T' + u = $1_input(x,zeros($Ny,1),t,par); + x = fsolve('f',x); + y = $1_odeo(x,u,t,par); + mtt_write(t,x,y,$Nx,$Ny); # Write it out +end; + +save -ascii $1_odess.dat2 MTT_data + +EOF + +# Now invoke the standard error handling. +mtt_error mtt_error.txt + + + + +