File mttroot/mtt/bin/trans/sm2sr_m artifact 870d94632e part of check-in 33c0c5ca89


#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: sm2sr_m

# Transforms descriptor matrix rep to step response


# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.11  1996/08/24  14:02:39  peter
# Included glabal parameter passing.
# Proper error handling.
#
## Revision 1.10  1996/08/19 15:34:14  peter
## Now based on state - not descriptor matrices.
##
## Revision 1.9  1996/08/18 12:01:45  peter
## Unified format of time responses.
##
## Revision 1.8  1996/08/15 16:23:39  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.7  1996/08/15 11:54:32  peter
## Now has optional initial condition.
##
## Revision 1.6  1996/08/14 09:15:02  peter
## Now encapsulates the data into an m file
## Name changed
##
## Revision 1.5  1996/08/12 20:19:06  peter
## Fiddled about with parameter passing - still not right
##
## Revision 1.4  1996/08/11 19:48:04  peter
## Parameter passing added.
##
## Revision 1.3  1996/08/11 10:38:30  peter
## Minor debugging changes.
##
## Revision 1.2  1996/08/11 10:06:50  peter
## Now allows e format and NaN numbers.
##
## Revision 1.1  1996/08/11 09:45:46  peter
## Initial revision
##
###############################################################

echo Creating $1_sr.m
echo Creating $1_sro.m
rm -f sm2sr_m.log
rm -f $1_sr.m
rm -f $1_sro.m
rm -f mtt_error

if [ "$2" = "" ]; 
then
  PARAMS='T=[0:0.1:10];u0=ones(nu,1);x0=zeros(nx,1);'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi

PARAMS="$PARAMS ;"

$MATRIX << EOF > sm2sr_m.log 2>mtt_error.txt

  % Read in the numeric system parameters
  $1_numpar;

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.

  $PARAMS

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('u0')==0
    u0 = ones(nu,1);
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;


  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D] = $1_sm;
  [y,x] = sm2sr(A,B,C,D,T,u0,x0);

  if nx>0
    write_matrix([T x], '$1_sr');
  end;
  if ny>0
    write_matrix([T y], '$1_sro');
  end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt



MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]