ADDED   mttroot/mtt/bin/trans/abg2cr_m2txt
Index: mttroot/mtt/bin/trans/abg2cr_m2txt
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/abg2cr_m2txt
@@ -0,0 +1,48 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: abg2cr_m2txt
+
+# Abg file to constitutive relationship conversion
+# P.J.Gawthrop march 2000
+# Copyright (C) 2000 by Peter J. Gawthrop
+
+
+
+# Inform user
+if [ -f "$1_cr.txt" ]; then
+    echo "Using  $1_cr.txt"
+    exit
+else
+    echo "Creating $1_cr.txt"
+fi
+
+
+rm -f mtt_error
+
+
+# This is the main transformation using awk 
+# And remove crs with same name as system
+grep 'cr = ' $1_abg.m | awk '
+BEGIN {
+# Include lin cr anyway.
+print "lin"
+}
+{
+  crs=substr($3,2,length($3)-3);
+    N=split(crs,cr,";");
+      for (i=1;i<=N;i++){
+        if (length(cr[i])>0)
+        print cr[i];
+      }
+}'  2>mtt_error.txt | sort -u | grep -v none | grep -v '\$[0-9]'> $1_cr.txt
+
+# Now invoke the standard error handling.
+mtt_error mtt_error.txt
+
+
+
+

ADDED   mttroot/mtt/bin/trans/cse2ode_r
Index: mttroot/mtt/bin/trans/cse2ode_r
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/cse2ode_r
@@ -0,0 +1,115 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: cse2ode_r
+# Reduce constrained-state equations to ode.
+# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Dec 1994
+# Copyright (c) P.J.Gawthrop, 1991, 1994.
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.2  1997/01/06 21:17:10  peterg
+## Removed:  OFF Exp; OFF GCD;
+##
+## Revision 1.1  1996/08/25 10:05:45  peter
+## Initial revision
+##
+###############################################################
+
+# Create the reduce output code
+def2write_r $1 ode
+def2write_r $1 odeo
+
+#Inform user
+echo Creating $1_ode.r
+echo Creating $1_odeo.r
+
+# Remove the old log file
+rm -f cse2ode_r.log
+
+# Use reduce to accomplish the transformation
+$SYMBOLIC >cse2ode_r.log << EOF
+
+%Read the formatting function
+in "$MTTPATH/trans/reduce_matrix.r";
+
+%Read the definitions file
+in "$1_def.r";
+
+%Read the substitution file
+in "$1_subs.r";
+
+%Read the constrained-state equations file
+in "$1_cse.r";
+
+IF MTTNx>0 THEN
+ IF MTTNz>0 THEN
+   MTTdXX := MTTE^(-1)*MTTEdX
+ ELSE
+   MTTdXX := MTTEdX;
+
+%Remove all dX terms from y - a rather nasty method, sorry!
+  MTTdX1 := 0;
+  MTTdX2 := 0;
+  MTTdX3 := 0;
+  MTTdX4 := 0;
+  MTTdX5 := 0;
+  MTTdX6 := 0;
+  MTTdX7 := 0;
+  MTTdX8 := 0;
+  MTTdX9 := 0;
+  MTTdX10 := 0;
+  MTTdX11 := 0;
+  MTTdX12 := 0;
+  MTTdX13 := 0;
+  MTTdX14 := 0;
+  MTTdX15 := 0;
+  MTTdX16 := 0;
+  MTTdX17 := 0;
+  MTTdX18 := 0;
+  MTTdX19 := 0;
+  MTTdX20 := 0;
+
+%Substitute  dX into y;
+IF MTTNz>0 THEN
+  IF MTTNx>0 THEN
+    MTTY := MTTY + MTTEyx*MTTdX;
+
+OFF Echo;
+OFF Nat;
+
+MTTdX := MTTdXX;
+
+%Write out the  ordinary differential equations.
+OUT "$1_ode.r";
+write "%File: $1_ode.r";
+in ("$1_ode_write.r");
+write "in ""$1_odeo.r"";";
+write "END;";
+SHUT "$1_ode.r";
+
+%Write out the  output equations
+OUT "$1_odeo.r";
+write "%File: $1_odeo.r";
+in ("$1_odeo_write.r");
+write "END;";
+SHUT "$1_odeo.r";
+quit;
+EOF
+
+# Now invoke the standard error handling.
+mtt_error_r cse2ode_r.log
+
+
+
+
+
+
+
+

ADDED   mttroot/mtt/bin/trans/cse2rfe_r
Index: mttroot/mtt/bin/trans/cse2rfe_r
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/cse2rfe_r
@@ -0,0 +1,181 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: cse2rfe_r
+# Reduce  constrained-state equations to robot matrices
+# Experimental version!
+# State vector should have momenta in odd rows,angles in even;
+# the last row should have the gravity velocity term.
+# There should be one output (only) for each joint velocity.
+# P.J.Gawthrop, Nov 92, Dec 93, May 1994
+# Copyright (c) P.J.Gawthrop, 1992, May 1994.
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.2  1996/12/05 12:10:00  peterg
+## Version history added.
+##
+###############################################################
+
+# Inform user
+echo Creating $1_rfe.r
+
+# Remove the old log file
+rm -f cse2rfe_r.log
+
+# Use reduce to accomplish the transformation
+reduce >cse2rfe_r.log << EOF
+
+IN "$1_def.r";
+IN "$1_sympar.r";
+IN "$1_csm.r";
+IN "$1_cse.r";
+
+MTTN2 := MTTNy;
+
+
+%Find E11 and E12 matrices
+MATRIX MTTE11(MTTN2,MTTN2), MTTE12(MTTN2,MTTN2);
+FOR i := 1:MTTN2 DO
+  FOR j := 1:MTTN2 DO
+  BEGIN
+    MTTE11(i,j) := MTTE(2*i-1,2*j-1);
+    MTTE12(i,j) := MTTE(2*i-1,2*j);
+  END;
+
+%Find inertia matrix
+MATRIX MTTImi(MTTN2,MTTN2);
+FOR i := 1:MTTN2 DO
+  BEGIN
+    MTTImi(i,i) := MTTC(i,2*i-1);
+   END;
+
+MTTIm := MTTImi^-1;
+
+%Find gravity matrix if there is an extra gravity state
+MATRIX MTTG(MTTN2,1);
+MTTNy2 := 2*MTTNy;
+IF ( (MTTNx-1)/MTTNy2 = 1) THEN
+FOR i := 1:MTTN2 DO
+  BEGIN
+    MTTG(i,1) := MTTE(2*i-1,MTTNx);
+   END;
+
+
+
+%Find V matrix from RHS of equation
+MTTu1 := 0;
+MTTu2 := 0;
+MTTu3 := 0;
+MTTu4 := 0;
+MTTu5 := 0;
+MTTu6 := 0;
+
+MTTx2 := theta_1;
+MTTx4 := theta_2;
+MTTx6 := theta_3;
+MTTx8 := theta_4;
+MTTx10 := theta_5;
+MTTx12 := theta_6;
+
+MTTx1 := dot_theta_1*MTTIm(1,1);
+MTTx3 := dot_theta_2*MTTIm(2,2);
+MTTx5 := dot_theta_3*MTTIm(2,3);
+
+MATRIX MTTdt(6,1);
+MTTdt(1,1) := dot_theta_1;
+MTTdt(2,1) := dot_theta_2;
+MTTdt(3,1) := dot_theta_3;
+MTTdt(4,1) := dot_theta_4;
+MTTdt(5,1) := dot_theta_5;
+MTTdt(6,1) := dot_theta_6;
+
+MATRIX dtheta(MTTN2,1);
+FOR i := 1:MTTN2 DO
+  BEGIN
+    dtheta(i,1) := MTTdt(i,1);
+   END;
+
+MATRIX MTTVrhs(MTTN2,1);
+MATRIX MTTV(MTTN2,1);
+FOR i := 1:MTTN2 DO
+  BEGIN
+    MTTVrhs(i,1) := MTTEdX(2*i-1,1);
+   END;
+
+%Find V matrix 
+MTTV := MTTE12*dtheta - MTTVrhs;
+
+%Find C matrix
+MATRIX MTTC(MTTN2,MTTN2);
+k := 0;
+FOR i := 1:MTTN2 DO
+  FOR j := 1:MTTN2 DO
+  BEGIN
+  coeffs := coeff(MTTV(i,1),MTTdt(j,1));
+  IF length(coeffs)>2 THEN co := part(coeffs,3) ELSE co := 0;
+  MTTC(i,j) := co;
+  END;
+
+%Find B matrix
+MTTN3 := MTTN2*(MTTN2-1)/2;
+
+IF MTTN3>0 THEN
+BEGIN
+MATRIX MTTB(MTTN2,MTTN3);
+FOR i := 1:MTTN2 DO
+BEGIN
+  counter := 0;
+  FOR j := 1:MTTN2-1 DO
+  BEGIN
+  coeffs := coeff(MTTV(i,1),MTTdt(j,1));
+  IF length(coeffs)>1 THEN co := part(coeffs,2) ELSE co := 0;
+    FOR k := j+1:MTTN2 DO
+    BEGIN 
+    counter := counter+1;
+    coeffs2 := coeff(co,MTTdt(k,1));
+    IF length(coeffs2)>1 THEN co2 := part(coeffs2,2) ELSE co2 := 0;
+     MTTB(i,counter) := co2;
+    END;
+  END;
+END;
+END;
+
+OFF Echo;
+OFF Nat;
+ON NERO;
+
+OUT "$1_rfe.r";
+
+%% M
+write "MATRIX MTTM(", MTTN2, ",", MTTN2, ")";
+MTTM := MTTE11*MTTIm;
+
+%% V
+write "MATRIX MTTRV(", MTTN2, ",1)";
+MTTRV := MTTV;
+
+%% 
+
+write "MATRIX MTTRC(", MTTN2, ",", MTTN2, ")";
+MTTRC := MTTC;
+
+IF MTTN3>0 THEN
+  BEGIN
+  write "MATRIX MTTRB(", MTTN2, ",", MTTN3, ")";
+  MTTRB := MTTRB;
+END;
+
+write "MATRIX MTTRG(", MTTN2, ", 1)";
+MTTRG := MTTG;
+
+write ";END;"$
+SHUT "$1_rfe.r";
+quit;
+EOF

ADDED   mttroot/mtt/bin/trans/csm2sm_r
Index: mttroot/mtt/bin/trans/csm2sm_r
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/csm2sm_r
@@ -0,0 +1,127 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: csm2sm_r
+# Constrained-state equation to linear constrained-state matrices conversion
+# P.J.Gawthrop  6th September 1991, May 1994
+# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.2  1996/08/25 10:11:32  peter
+## Added END in output file.
+## Error handling.
+##
+## Revision 1.1  1996/08/19 15:06:16  peter
+## Initial revision
+##
+###############################################################
+
+# Create the reduce output code
+def2write_r $1 $2
+
+# Inform user
+echo Creating $1_$2.r
+
+case $2 in
+    sm)
+        rep=csm;
+        ;;
+    ssm)
+        rep=scsm
+        ;;
+    *)
+        echo Representation must be sm or ssm
+esac
+
+# Remove the old log file
+rm -f csm2sm_r.log
+
+# Use reduce to accomplish the transformation
+$SYMBOLIC >csm2sm_r.log << EOF
+
+in "$1_def.r";
+in "$1_$rep.r";
+in "$1_cr.r";
+%%in "$1_sympar.r";
+
+OFF Echo;
+OFF Nat;
+
+% Find MTTA and MTTB : the A and B matrices
+
+MTTinvE := MTTE^(-1);
+MTTA := MTTinvE*MTTA;
+MTTB := MTTinvE*MTTB;
+
+% Create the matrix declarations
+OUT "$1_$2.r1";
+write "MATRIX MTTA(", MTTNx, ",", MTTNx, ")$"; 
+write "MATRIX MTTB(", MTTNx, ",", MTTNu, ")$"; 
+write "MATRIX MTTC(", MTTNy, ",", MTTNx, ")$"; 
+write "MATRIX MTTD(", MTTNy, ",", MTTNu, ")$"; 
+SHUT "$1_$2.r1";
+
+%Create the output file
+OUT "$1_$2.r2";
+write "%File: $1_ode.r";
+
+write "% New constants";
+write "MTTNx := ", MTTNx, ";";
+write "MTTNy := ", MTTNy, ";";
+
+in ("$1_sm_write.r");
+
+%Write out the matrices.
+% IF MTTNx>0 THEN
+% BEGIN
+%   write "matrix MTTA(", MTTNx, ",", MTTNx, ");";
+%   FOR i := 1:MTTNx DO
+%    FOR j := 1:MTTNx DO IF MTTA(i,j) NEQ 0 THEN
+%       write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
+% END;
+
+% IF MTTNx>0 THEN
+% IF MTTNu>0 THEN
+% BEGIN
+%   write "matrix MTTB(", MTTNx, ",", MTTNu, ");";
+%   FOR i := 1:MTTNx DO
+%    FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
+%       write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
+% END;
+
+% %Write it out
+% IF MTTNy>0 THEN
+% IF MTTNx>0 THEN
+% BEGIN
+%   write "matrix MTTC(", MTTNy, ",", MTTNx, ");";
+%   FOR i := 1:MTTNy DO
+%     FOR j := 1:MTTNx DO IF MTTC(i,j) NEQ 0 THEN
+%       write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
+% END;
+
+% IF MTTNy>0 THEN IF MTTNu>0 THEN 
+% BEGIN
+%   write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
+%   FOR i := 1:MTTNy DO
+%     FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
+%       write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
+% END;
+
+write "END;";
+
+SHUT "$1_$2.r2";
+quit;
+
+EOF
+
+cat $1_$2.r1 $1_$2.r2 > $1_$2.r
+
+# Now invoke the standard error handling.
+mtt_error_r csm2sm_r.log

ADDED   mttroot/mtt/bin/trans/csm_r2m
Index: mttroot/mtt/bin/trans/csm_r2m
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/csm_r2m
@@ -0,0 +1,114 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: csm_r2m
+# Reduce constained state-space A,B,C,D and E matrices to Matlab
+# P.J.Gawthrop July 1990, Feb 1991, May 1991, Sep 91, Dec 93, Jan 94, May 94.
+# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994.
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.2  1996/08/19 18:40:02  peter
+## read in the nuim_par function etc.
+##
+## Revision 1.1  1996/08/19 16:27:04  peter
+## Initial revision
+##
+###############################################################
+
+# Inform user
+echo Creating $1_$2.m
+
+# Remove the old log file
+rm -f csm_r2m.log
+
+# Use reduce to accomplish the transformation
+reduce >csm_r2m.log << EOF
+
+%Read in the definitions file
+in "$1_def.r";
+
+%Read the reduce state-space A,B,C and D matrices file
+in "$1_$2.r";
+
+%Set up the number of argument variables to zero in case the user has forgotten
+MTTNVar := 0;
+
+%Read in the parameter file
+%%in "$1_sympar.r";
+
+
+OUT "$1_$2.m";
+
+%Headings - Matlab style
+%(Note. The ;; are deleted by for2mat)
+
+IF MTTNvar>0 THEN
+BEGIN
+  write "function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2(...";
+  FOR i := 1:MTTNvar DO
+  BEGIN
+     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
+                  ELSE write MTTVar(i,1), ");;";
+  END;
+END
+ELSE write "function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2;;";
+
+
+IF MTTNvar>0 THEN
+BEGIN
+  write "%function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2(...";
+  FOR i := 1:MTTNvar DO
+  BEGIN
+     IF i<MTTNvar THEN write "%", MTTVar(i,1), ",..."
+                  ELSE write "%", MTTVar(i,1), ");;";
+  END;
+END
+ELSE write "%function [MTTA,MTTB,MTTC,MTTD,MTTE] = $1_$2;;";
+
+
+write "%Linearised constrained-state matrices for system $1";
+write "%File $1_$2.m";
+write "%Generated by MTT";
+
+IF MTTNvar>0 THEN
+BEGIN
+  write "% Read in the parameters";
+  write "[ ...;;";
+  FOR i := 1:MTTNvar DO
+  BEGIN
+     IF i<MTTNvar THEN write MTTVar(i,1), ",..."
+                  ELSE write MTTVar(i,1), "] = $1_numpar"
+  END;
+  write "% Read in the arguments";
+  write "$1_args";
+END;
+
+%Fortran switches - one line expressions
+OFF echo;
+ON fort$
+cardno!* := 1$
+fortwidth!* := 100$
+OFF period$
+
+write "MTTA = zeros(", MTTNx, ",", MTTNx, ");";
+write "MTTB = zeros(", MTTNx, ",", MTTNu, ");";
+write "MTTC = zeros(", MTTNy, ",", MTTNx, ");";
+write "MTTD = zeros(", MTTNy, ",", MTTNu, ");";
+write "MTTE = zeros(", MTTNx, ",", MTTNx, ");";
+
+ON NERO;	% Suppress zero elements.
+MTTA := MTTA;
+MTTB := MTTB;
+MTTC := MTTC;
+MTTD := MTTD;
+MTTE := MTTE;
+
+SHUT "$1_$2.m";
+

ADDED   mttroot/mtt/bin/trans/csm_r2tex
Index: mttroot/mtt/bin/trans/csm_r2tex
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/csm_r2tex
@@ -0,0 +1,83 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: csm_r2tex
+# Reduce constrained-state matrices to LaTex constrained-state matrices.
+# P.J.Gawthrop  9 Sep 1991, May 1994
+# Copyright (c) P.J.Gawthrop, 1991, May 1994.
+
+# Inform user
+echo Creating $1_$2.tex
+
+# Remove the old log file
+rm -f csm_r2tex.log
+
+# Use reduce to accomplish the transformation
+reduce >csm_r2tex.log << EOF
+
+%Read the definitions file
+in "$1_def.r";
+
+%Read the constrained-state matrices file
+in "$1_$2.r";
+
+%Read the symbolic parameters file
+%%in "$1_sympar.r";
+
+%Read the substitution file
+in "$1_subs.r";
+
+%Read the simplification file
+in "$1_simp.r";
+
+%Read the formatting function
+in "$MTTPATH/trans/latex_matrix.r";
+
+OFF Echo;
+OFF Nat;
+
+OUT "$1_$2.tex";
+
+%Write out the constrained-state matrices.
+write "%constrained-state  matrices $1";
+write "%File: $1_$2.tex";
+write"";
+
+write "%constrained-state matrices";
+
+MTT_Matrix := MTTA$ 
+MTT_Matrix_name := "MTTA"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+LaTeX_Matrix()$
+
+MTT_Matrix := MTTB$ 
+MTT_Matrix_name := "MTTB"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNu$
+LaTeX_Matrix()$
+
+MTT_Matrix := MTTC$ 
+MTT_Matrix_name := "MTTC"$
+MTT_Matrix_n := MTTNy$
+MTT_Matrix_m := MTTNx$
+LaTeX_Matrix()$
+
+MTT_Matrix := MTTD$ 
+MTT_Matrix_name := "MTTD"$
+MTT_Matrix_n := MTTNu$
+MTT_Matrix_m := MTTNu$
+LaTeX_Matrix()$
+
+MTT_Matrix := MTTE$ 
+MTT_Matrix_name := "MTTE"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+LaTeX_Matrix()$
+
+SHUT "$1_$2.tex";
+quit;
+EOF

ADDED   mttroot/mtt/bin/trans/dat2gdat
Index: mttroot/mtt/bin/trans/dat2gdat
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/dat2gdat
@@ -0,0 +1,128 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: dat2gdat
+
+# Converts a data file in data format to gplot data format
+
+# Copyright (c) P.J.Gawthrop, 1997.
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.8  1998/09/29 20:01:27  peterg
+## 4th argument for nyquist style files - ie differnt x for each y
+##
+## Revision 1.7  1997/12/04 22:10:32  peterg
+## Handles argument list - variable names.
+##
+## Revision 1.6  1997/05/22 10:34:05  peterg
+## Changed argument structure.
+##
+## Revision 1.5  1997/05/22 10:11:19  peterg
+## Fixed parametetr bug
+##
+# Revision 1.4  1997/05/16  13:03:10  peterg
+# Now selects variables to display.
+#
+# Revision 1.3  1996/08/26  13:02:58  peterg
+# Cahged awk to awk.
+#
+# Revision 1.2  1996/08/15  11:49:11  peter
+# Puts a blank line at the end of the file:
+#  this allows user to cat files for use in gnuplot.
+#
+## Revision 1.1  1996/08/14 09:13:52  peter
+## Initial revision
+##
+###############################################################
+
+echo Creating $1_$2.gdat
+rm -f $1_$2.gdat
+
+DifferentX=$4;
+
+# Convert multi-columns into gnuplot format -
+# ie stack two columns vertically separated by blank lines
+
+#Get the desired data index
+which=`name2index $1 "$3"`
+
+if [ -z "$DifferentX" ]; then
+awk '
+BEGIN{
+  row=0; col=0;
+}
+{ 
+  if (row==0) {
+     N=split(which,Which,",");
+    }
+  row++;
+  j=1;
+  if (Which[1]==0) {
+    x[row] = $1;
+    for (i=1; i<NF; i++) {
+      ycol = i+1;
+      y[row,j++] = $ycol;
+    }
+  }
+  else {
+  xcol = Which[1];
+  x[row] = $xcol
+  for (i=1; i<N; i++) {
+      ycol = Which[i+1];
+      y[row,j++] = $ycol;
+    }
+  }
+  cols=j-1;
+}
+END {
+  rows = row;
+  for (col = 1; col <= cols; col++) {
+    for (row = 1; row <= rows; row++) {
+      print x[row], y[row,col]
+    };
+  if (col<=cols) {
+    printf("\n")
+  }
+  }
+}'  which="$which" <$1_$2.dat >   $1_$2.gdat
+
+else
+awk '
+BEGIN{
+  row=0; col=0;
+}
+{ 
+  row++; cols=NF/2
+    for (i=1; i<=cols; i++) {
+      ycol=2*i;
+      xcol=ycol-1;
+      x[row,i] = $xcol
+      y[row,i] = $ycol;
+    }
+}
+END {
+  rows = row;
+  for (col = 1; col <= cols; col++) {
+    for (row = 1; row <= rows; row++) {
+      print x[row,col], y[row,col]
+    };
+  if (col<=cols) {
+    printf("\n")
+  }
+  }
+}'   <$1_$2.dat >   $1_$2.gdat
+    
+fi
+
+
+
+
+
+

ADDED   mttroot/mtt/bin/trans/dat2sdat
Index: mttroot/mtt/bin/trans/dat2sdat
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/dat2sdat
@@ -0,0 +1,45 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: dat2sdat
+
+# Structure file - dat to sdat conversion
+# P.J.Gawthrop April 1997
+# Copyright (c) P.J.Gawthrop, 1997, 1999
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.1  1999/03/28 21:29:40  peterg
+## Initial revision
+##
+###############################################################
+
+if [ "$2" = "odes" ]; then
+    which="state"
+else
+    which="output"
+fi
+
+awk '
+BEGIN{
+printf("Time");
+}
+{ 
+  if ($1==which)
+    printf(" %s(%s)", $3, $5);
+}
+END{
+printf("\n");
+}
+'  SYSTEM=$1 which=$which  < $1_struc.txt
+
+cat $1_$2.dat
+
+
+

ADDED   mttroot/mtt/bin/trans/dm_r2tex
Index: mttroot/mtt/bin/trans/dm_r2tex
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/dm_r2tex
@@ -0,0 +1,163 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: dm_r2tex
+# Reduce descriptor matrices to LaTex descriptor matrices.
+# P.J.Gawthrop 9 June 1990, 8th July 1990, 14 Feb 1991, 10th May 1991, 4th June 1991
+# Copyright (c) P.J.Gawthrop, 1990, 1991.
+
+#Inform user
+echo Creating $1_dm.tex
+
+# Remove the old log file
+rm -f dm_r2tex.log
+
+# Use reduce to accomplish the transformation
+reduce >dm_r2tex.log << EOF
+
+%Read the definitions file
+in "$1_def.r";
+
+%Read the symbolic parameters file
+%%in "$1_sympar.r";
+
+%Read the substitution file
+in "$1_subs.r";
+
+%Read the simplification file
+in "$1_simp.r";
+
+%Number of descriptor variables
+MTTN := MTTNx + 2*MTTNz + MTTNyz;
+
+%Read the descriptor matrices file
+in "$1_dm.r";
+
+OFF Echo;
+OFF Nat;
+
+OUT "$1_dm.tex";
+
+%Write out the descriptor matrices.
+write "%Descriptor matrices $1";
+write "%File: $1_dm.tex";
+write"";
+
+write "%Descriptor matrices";
+
+%IF (MTTNz+MTTNyz) NEQ 0 THEN
+%BEGIN
+%  write "%  - E matrix";
+%  write "\begin{equation}";
+%  write "MTTE = MTTI_0(", MTTNx+MTTNz, ",", MTTNz+MTTNyz, ")";
+%  write "\end{equation}";
+%END;
+
+
+IF MTTN NEQ 0 THEN
+IF (MTTNz+MTTNyz) > 0 THEN
+BEGIN
+write "%  - E matrix";
+write "\begin{equation}";
+write "MTTE = \begin{pmatrix}";
+	FOR Row := 1:MTTN DO
+	BEGIN
+		FOR Col := 1:MTTN DO
+		BEGIN
+			Write "{", MTTE(Row,Col), "}";
+			IF Col<MTTN THEN Write "&"
+		END;
+
+	IF Row<MTTN THEN Write "\cr";
+	END;
+	Write "\end{pmatrix}";
+write "\end{equation}";
+END;
+
+
+
+IF MTTN NEQ 0 THEN
+BEGIN
+write "%  - A matrix";
+write "\begin{equation}";
+write "MTTA = \begin{pmatrix}";
+	FOR Row := 1:MTTN DO
+	BEGIN
+		FOR Col := 1:MTTN DO
+		BEGIN
+			Write "{", MTTA(Row,Col), "}";
+			IF Col<MTTN THEN Write "&"
+		END;
+
+	IF Row<MTTN THEN Write "\cr";
+	END;
+	Write "\end{pmatrix}";
+write "\end{equation}";
+END;
+
+IF MTTN NEQ 0 THEN IF MTTNu NEQ 0 THEN
+BEGIN
+write "%  - B matrix";
+write "\begin{equation}";
+write "MTTB = \begin{pmatrix}";
+	FOR Row := 1:MTTN DO
+	BEGIN
+		FOR Col := 1:MTTNu DO
+		BEGIN
+			Write "{", MTTB(Row,Col), "}";
+			IF Col<MTTNu THEN Write "&"
+		END;
+
+	IF Row<MTTN THEN Write "\cr";
+	END;
+	Write "\end{pmatrix}";
+write "\end{equation}";
+END;
+
+IF MTTN NEQ 0 THEN IF MTTNy NEQ 0 THEN
+BEGIN
+write "%  - C matrix";
+write "\begin{equation}";
+write "MTTC = \begin{pmatrix}";
+	FOR Row := 1:MTTNy DO
+	BEGIN
+		FOR Col := 1:MTTN DO
+		BEGIN
+			Write "{", MTTC(Row,Col), "}";
+			IF Col<MTTN THEN Write "&"
+		END;
+
+	IF Row<MTTNy THEN Write "\cr";
+	END;
+	Write "\end{pmatrix}";
+write "\end{equation}";
+END;
+
+IF MTTNy NEQ 0 THEN IF MTTNu NEQ 0 THEN
+BEGIN
+write "%  - D matrix";
+write "\begin{equation}";
+write "MTTD = \begin{pmatrix}";
+	FOR Row := 1:MTTNy DO
+	BEGIN
+		FOR Col := 1:MTTNu DO
+		BEGIN
+			Write "{", MTTD(Row,Col), "}";
+			IF Col<MTTNu THEN Write "&"
+		END;
+
+	IF Row<MTTNy THEN Write "\cr";
+	END;
+	Write "\end{pmatrix}";
+write "\end{equation}";
+END;
+
+
+
+
+SHUT "$1_dm.tex";
+quit;
+EOF

Index: mttroot/mtt/bin/trans/lbl2cr_txt2r
==================================================================
--- mttroot/mtt/bin/trans/lbl2cr_txt2r
+++ mttroot/mtt/bin/trans/lbl2cr_txt2r
@@ -13,10 +13,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+# Revision 1.3  1996/11/03  21:11:44  peterg
+# Removed END; statement
+#
 ## Revision 1.2  1996/11/02 10:20:53  peterg
 ## Created from lbl2sympar
 ##
 ###############################################################
 
@@ -28,13 +31,13 @@
 
 #Write some file headers
 echo "%% constitutive relationship  file ($1_cr.r)" > $1_cr.r
 echo "%% Generated by MTT at `date`" >> $1_cr.r
 
-# This is the main transformation using gawk
-gawk -f $MTTPATH/trans/awk/lbl2cr.awk <$1_lbl.txt  2>mtt_error.txt | \
+# This is the main transformation using awk
+awk -f $MTTPATH/trans/awk/lbl2cr.awk <$1_lbl.txt  2>mtt_error.txt | \
 	sh >> $1_cr.r
 
 # Now invoke the standard error handling.
 #mtt_error mtt_error.txt
 
 

Index: mttroot/mtt/bin/trans/lbl2sympar_txt2r
==================================================================
--- mttroot/mtt/bin/trans/lbl2sympar_txt2r
+++ mttroot/mtt/bin/trans/lbl2sympar_txt2r
@@ -13,10 +13,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+# Revision 1.6  1996/12/07  19:39:51  peterg
+# Minor debugging.
+#
 ## Revision 1.5  1996/09/12 17:18:44  peter
 ## Don't add an RCS header ..
 ##
 ## Revision 1.4  1996/08/30 19:01:21  peter
 ## Added headers to sympar file.
@@ -40,13 +43,13 @@
 
 #Write some file headers
 echo "%% Symbolic parameter file ($1_sympar.r)" > $1_sympar.r
 echo "%% Generated by MTT at `date`" >> $1_sympar.r
 
-# This is the main transformation using gawk
+# This is the main transformation using awk
 tr ';' ',' <  $1_lbl.txt | \
-gawk -f $MTTPATH/trans/awk/lbl2sympar.awk >> $1_sympar.r 2>mtt_error.txt
+awk -f $MTTPATH/trans/awk/lbl2sympar.awk | sort >> $1_sympar.r 2>mtt_error.txt
 
 # Now invoke the standard error handling.
 mtt_error mtt_error.txt
 
 

Index: mttroot/mtt/bin/trans/lbl_txt2tex
==================================================================
--- mttroot/mtt/bin/trans/lbl_txt2tex
+++ mttroot/mtt/bin/trans/lbl_txt2tex
@@ -12,10 +12,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.9  2000/11/16 13:11:06  peterg
+## Included PAR and UNITS declarations
+##
 ## Revision 1.8  1999/02/17 21:42:19  peterg
 ## Replaced print by printf to avoid extra nl in paragraph command.
 ##
 ## Revision 1.7  1998/07/27 12:56:26  peterg
 ## Splits up | separated expressions.
@@ -123,13 +126,21 @@
 }' >> $1_lbl.tex
 cat <<EOF >> $1_lbl.tex
 \end{description}
 EOF
 
-
+# Write the actual lbl file
+cat >> $1_lbl.tex <<EOF
+\subsubsection*{The label file: $1\_lbl.txt}
+\begin{verbatim}
+EOF
+cat $1_lbl.txt >> $1_lbl.tex
+cat >> $1_lbl.tex <<EOF
+\end{verbatim}
+EOF
 
 
 
 
 
 
 

ADDED   mttroot/mtt/bin/trans/lde_r2tex
Index: mttroot/mtt/bin/trans/lde_r2tex
==================================================================
--- /dev/null
+++ mttroot/mtt/bin/trans/lde_r2tex
@@ -0,0 +1,106 @@
+#! /bin/sh
+
+     ###################################### 
+     ##### Model Transformation Tools #####
+     ######################################
+
+# Bourne shell script: lde_r2tex
+# Reduce differential-algebraic to LaTex differential-algebraic equations.
+# P.J.Gawthrop 10th May 1991, April 1994
+# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996.
+
+###############################################################
+## Version control history
+###############################################################
+## $Id$
+## $Log$
+## Revision 1.3  1998/01/23 15:51:01  peterg
+## Repleace eqnarray by equation + aligned -- this works with Latex2html
+##
+## Revision 1.2  1996/12/20 08:59:10  peterg
+## Now writes out mtti instead of mtt_{i} -- lets latex_tidy do the
+## conversion.
+##
+## Revision 1.1  1996/12/20 08:53:57  peterg
+## Initial revision
+##
+###############################################################
+
+# Inform user
+echo Creating $1_lde.tex
+
+# Remove the old log file
+rm -f lde_r2tex.log
+
+# Use reduce to accomplish the transformation
+reduce >lde_r2tex.log << EOF
+
+%Read the definitions file
+in "$1_def.r";
+
+%Read the differential-algebraic equations file
+in "$1_lde.r";
+
+%Read the symbolic parameter file
+%%in "$1_sympar.r";
+
+
+
+OFF Echo;
+OFF Nat;
+
+%Read the substitution file
+IN "$1_subs.r";
+
+%Read the simplifying expressions file
+IN "$1_simp.r";
+
+OUT "$1_lde.tex";
+
+%Write out the  differential-algebraic equations.
+
+write "%File: $1_lde.tex";
+
+write "%ordinary differential equations";
+write "% Generated by MTT";
+
+IF MTTNyz>0 THEN
+BEGIN
+  write"\begin{equation} \label{eq_$1_lde_x}";
+  write"\begin{aligned}";
+  FOR Row := 1:MTTNx DO
+  BEGIN
+	write "{";
+	write MTTl(Row,1);
+	write "}";
+	write " &= 0";
+        IF Row<MTTNx THEN write "\cr";
+  END;
+  write"\end{aligned}";
+  write"\end{equation}";
+END;
+
+
+IF MTTNy>0 THEN
+BEGIN
+  write"\begin{equation} \label{eq_$1_lde_y}";
+  write"\begin{aligned}";
+  FOR Row := 1:MTTNy DO
+  BEGIN
+	write "MTTy", Row, " &= ";
+	write "{";
+	write MTTy(Row,1);
+	write "}";
+        IF Row<MTTNy THEN write "\cr";
+  END;
+  write"\end{aligned}";
+  write"\end{equation}";
+END;
+
+
+
+
+
+SHUT "$1_lde.tex";
+quit;
+EOF

Index: mttroot/mtt/bin/trans/matlab_header
==================================================================
--- mttroot/mtt/bin/trans/matlab_header
+++ mttroot/mtt/bin/trans/matlab_header
@@ -4,13 +4,14 @@
      ##### Model Transformation Tools #####
      ######################################
 
 # Bourne shell script: matlab_header
 # Generic octave function header
+
 
 #Write some file headers
-echo "function [A,B,C,D,E] = $1_$2" 
+echo "function [$3] = $1_$2" 
 echo "% $2 function for system $1 ($1_$2.m)"   
 echo "% Generated by MTT at `date`"  
 echo  
 
 #Globals

Index: mttroot/mtt/bin/trans/matlab_matrix.r
==================================================================
--- mttroot/mtt/bin/trans/matlab_matrix.r
+++ mttroot/mtt/bin/trans/matlab_matrix.r
@@ -10,17 +10,20 @@
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % % Version control history
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % % $Id$
 % % $Log$
+% % Revision 1.1  1998/03/22 10:26:47  peterg
+% % Initial revision
+% %
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 % Load the general translator package
 LOAD GENTRAN;
 GENTRANLANG!* := 'FORTRAN;
 ON GENTRANSEG;
-MAXEXPPRINTLEN!* := 80;
+MAXEXPPRINTLEN!* := 400;
 
 PROCEDURE matlab_Matrix;
 BEGIN
   ON NERO;
   write "mtt_matrix = zeros(", mtt_matrix_n, ",", mtt_matrix_m, ");";

Index: mttroot/mtt/bin/trans/mtt_error
==================================================================
--- mttroot/mtt/bin/trans/mtt_error
+++ mttroot/mtt/bin/trans/mtt_error
@@ -12,10 +12,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.7  1998/03/06 17:14:09  peterg
+## Cospetic change to message
+##
 ## Revision 1.6  1998/03/05 10:17:41  peterg
 ## Cosmetic change
 ##
 ## Revision 1.5  1998/03/05 10:14:37  peterg
 ## Toned down the error warning message
@@ -40,11 +43,11 @@
 # Test for errors and print if any
 err_length=`wc -c <$error_file | awk '{print $1}'`
 if [ "$err_length" != "0" ]
 then
   echo "INFORMATION: An MTT transformation has generated the following messages"
-  echo "             (which may not be important)"
+#  echo "             (which may not be important)"
   cat $error_file
   exit 1
 else
   exit 0
 fi

Index: mttroot/mtt/bin/trans/mtt_getsize
==================================================================
--- mttroot/mtt/bin/trans/mtt_getsize
+++ mttroot/mtt/bin/trans/mtt_getsize
@@ -15,19 +15,29 @@
 while [ -n "`echo $1 | grep '^-'`" ]; do
   case $1 in
 	-internal )
                 internal=yes;
 		;;
+	-external )
+                external=yes;
+		;;
 	*)
 		echo "$1 is an invalid argument - ignoring";
                 exit ;;
   esac
   shift
 done
 
 if [ -n "$internal" ]; then
-    grep "MTT$2[^(]" $1_ese.r | wc -l
+    name=MTT$2"[0-9]"; # echo $name
+    grep -i "$name" $1_ese.r | wc -l
+    exit
+fi
+
+if [ -n "$external" ]; then
+    name="^MTT"$2"("; #echo $name
+    grep -i "$name" $1_ese.r | wc -l
     exit
 fi
 
 ## The original version for external sizes.
 if [ "$2" = "xx" ]; then

Index: mttroot/mtt/bin/trans/obs_r2m
==================================================================
--- mttroot/mtt/bin/trans/obs_r2m
+++ mttroot/mtt/bin/trans/obs_r2m
@@ -120,10 +120,11 @@
 else
     lang_header $1 obs m x,u yy > $1_obs.m1
 fi
 
 # Put together the pieces
+matlab_tidy $1_obs.m2
 matlab_tidy $1_obs.m3
 cat   $1_obs.m? >$1_obs.m
 
 rm -f $1_obs.m?
 

Index: mttroot/mtt/bin/trans/obs_r2tex
==================================================================
--- mttroot/mtt/bin/trans/obs_r2tex
+++ mttroot/mtt/bin/trans/obs_r2tex
@@ -12,10 +12,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.1  1998/04/07 08:30:20  peterg
+## Initial revision
+##
 # Revision 1.3  1997/06/13  13:50:11  peterg
 # Matrices in amstex format
 #
 # Revision 1.2  1997/04/18  12:54:00  peterg
 # No longer does labels.
@@ -41,10 +44,13 @@
 %Read the obs file
 in "$1_obs.r";
 
 %Read the Obs function parameters
 in "$1_obspar.r";
+
+%Read the substitution file
+in "$1_subs.r";
 
 %Read the simplification parameters
 in "$1_simp.r";
 
 %Read the formatting function
@@ -54,17 +60,10 @@
 OFF Nat;
 OFF EXP;
 
 OUT "$1_obs.tex";
 
-% Write the obs vector (YY)
-MTT_Matrix := MTTYY$ 
-MTT_Matrix_name := "MTTO"$
-MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
-MTT_Matrix_m := 1$
-LaTeX_Matrix()$
-
 % Write the affine form
 IF affine=1 THEN 
 BEGIN
   MTT_Matrix := MTTObs_o$ 
   MTT_Matrix_name := "MTTO_o"$
@@ -75,9 +74,19 @@
   MTT_Matrix := MTTObs_h$ 
   MTT_Matrix_name := "MTTO_h"$
   MTT_Matrix_n := (MTTGPCNy+1)*MTTNy$
   MTT_Matrix_m := (MTTGPCNu+1)*MTTNu$
   LaTeX_Matrix()$
+END
+ELSE
+BEGIN
+% Write the obs vector (YY)
+  MTT_Matrix := MTTYY$ 
+  MTT_Matrix_name := "MTTO"$
+  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
+  MTT_Matrix_m := 1$
+  LaTeX_Matrix()$
 END;
+
 SHUT "$1_obs.tex";
 quit;
 EOF

Index: mttroot/mtt/bin/trans/ode2odes_m
==================================================================
--- mttroot/mtt/bin/trans/ode2odes_m
+++ mttroot/mtt/bin/trans/ode2odes_m
@@ -13,10 +13,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.17  1998/06/27 14:49:16  peterg
+## No change
+##
 ## Revision 1.16  1998/06/25 08:47:23  peterg
 ## Put correct arguments for _input -- (x,t)
 ##
 ## Revision 1.15  1998/05/21 16:20:27  peterg
 ## Modified to include explicit algebraic loop solution
@@ -143,11 +146,12 @@
     for t=T'
       X = [X; xx'];
       ts = t;
       for i=1:STEPFACTOR
         x = xx(1:nx);
-        xx = $1_ode(xx,ts);
+        u = $1_input(xx,ts);
+        xx = $1_ode(xx,u,ts);
         ts = ts + dt;
         dx = xx(1:nx);
         x = x + dx*dt;
         xx(1:nx) = x;
       end;
@@ -154,19 +158,20 @@
     end;
   elseif strcmp(method,'implicitl')
     %Euler integration
     X=[];
     dt = (T(2)-T(1))/STEPFACTOR;
-    u = $1_input(x,t);
-    A = $1_sm(x,u); 
+    u = $1_input(x,u,t);
+    A = $1_smx(x,u); 
     inverse = inv(eye(nx) - dt*A);
     for t=T'
       X = [X; xx'];
       ts = t;
+      u = $1_input(x,t);
       for i=1:STEPFACTOR
         x = xx(1:nx);
-        xx = $1_ode(xx,ts);
+        xx = $1_ode(xx,u,ts);
         ts = ts + dt;
         dx = xx(1:nx);
         x = inverse*(x + dt*(dx - A*x));
         xx(1:nx) = x;
       end;
@@ -180,12 +185,12 @@
       X = [X; xx'];
       ts = t;
       for i=1:STEPFACTOR
         x = xx(1:nx);
         u = $1_input(x,t);
-    	A = $1_sm(x,u); 
-        xx = $1_ode(xx,ts);
+    	A = $1_smx(x,u); 
+        xx = $1_ode(xx,u,ts);
         ts = ts + dt;
         dx = xx(1:nx);
         x = (One-A*dt)\(x + dt*(dx - A*x));
         xx(1:nx) = x;
       end;
@@ -201,11 +206,12 @@
 
 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);
+    u = $1_input(x,t);
+    y = $1_odeo(X(i,:)',u,t);
     Y = [Y; y'];
   end;
   write_matrix([T,Y], '$1_odeso');
 end;
 

Index: mttroot/mtt/bin/trans/ode2odess_m
==================================================================
--- mttroot/mtt/bin/trans/ode2odess_m
+++ mttroot/mtt/bin/trans/ode2odess_m
@@ -13,10 +13,13 @@
 ###############################################################
 ## 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.
@@ -39,22 +42,23 @@
 ###############################################################
 
 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
-  $1_numpar;
-
-  [nx,ny,nu,nz,nyz] = $1_def;
-
+  par = $1_numpar;
 
    %Read in simulation parameters
-  $1_simpar;
-  T = [0:DT:LAST];
+  simpar=$1_simpar;
+  T = [0:simpar.dt:simpar.last];
 
   t=0;	%Just in case it appears in the parameter list.
 
 
   %Defaults
@@ -61,11 +65,11 @@
   if exist('T')==0
     T=[0:0.1:1]
   end;
 
   if exist('x0')==0
-    x0 = zeros(nx,1);
+    x0 = zeros($Nx,1);
   end;
 
   [n,m]=size(T);
   if m>n
     T=T';
@@ -72,23 +76,27 @@
   end;
 
 global t;
 function dx=f(x)
   global t
- dx = $1_ode(x,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'
-  i=i+1;
-  x(i,:) = fsolve('f',x0)';
+  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;
-  y(i,:) = $1_odeo(x(i,:),t)';
 end;
 
 write_matrix([T,x], '$1_odess');
 write_matrix([T,y], '$1_odesso');
 

Index: mttroot/mtt/bin/trans/ode2smx_lang
==================================================================
--- mttroot/mtt/bin/trans/ode2smx_lang
+++ mttroot/mtt/bin/trans/ode2smx_lang
@@ -12,10 +12,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.11  1998/11/26 10:32:34  peterg
+## Include subs.r
+##
 ## Revision 1.10  1998/11/17 17:10:22  peterg
 ## Read in the constitutive relationship file as well
 ##
 ## Revision 1.9  1998/08/27 07:06:25  peterg
 ## Just genrate xj once.
@@ -187,11 +190,12 @@
 
 EOF
 
 if [ "$lang" = "m" ]; then
   mv $1_smx.$lang  mtt_junk
-  lang_header $1 smx m 'mttx,mttu,mttdt' '[mtta,mttax]' > $1_smx.m
+#  lang_header $1 smx m 'mttx,mttu,mttdt' '[mtta,mttax]' > $1_smx.m
+  mtt_header $1 $2 m
   cat mtt_junk | mtt_p2m >> $1_smx.m
   rm -f mtt_junk
 
 #  mv $1_smxx.$lang  mtt_junk
 #  lang_header $1 smxx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxx.m

Index: mttroot/mtt/bin/trans/odeso_dat2sdat
==================================================================
--- mttroot/mtt/bin/trans/odeso_dat2sdat
+++ mttroot/mtt/bin/trans/odeso_dat2sdat
@@ -13,34 +13,17 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.1  1999/03/28 21:29:40  peterg
+## Initial revision
+##
 ###############################################################
 
 
 
 # Inform user
 echo "Creating $1_odeso.sdat"
 
-rm -f mtt_error
-
-# This is the main transformation using gawk
-gawk '
-
-BEGIN{
-printf("Time");
-}
-{ if ($1=="output")
-    printf(" %s(%s)", $3, $5);
-}
-END{
-printf("\n");
-}
-'  SYSTEM=$1  < $1_struc.txt > $1_odeso.sdat 2>mtt_error.txt
-
-cat $1_odeso.dat >> $1_odeso.sdat 2>>mtt_error.txt
-
-# Now invoke the standard error handling.
-mtt_error mtt_error.txt
-
+dat2sdat $1 odeso | dat2siag > $1_odeso.sdat
 

Index: mttroot/mtt/bin/trans/rdae2dae_r
==================================================================
--- mttroot/mtt/bin/trans/rdae2dae_r
+++ mttroot/mtt/bin/trans/rdae2dae_r
@@ -12,10 +12,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.4  2000/09/04 08:42:53  peterg
+## Put in extra echo to space output
+##
 ## Revision 1.3  2000/09/02 15:55:11  peterg
 ## Now doesn't include def files in da files
 ##
 ## Revision 1.2  2000/09/01 13:36:15  peterg
 ## Added -partition option
@@ -171,58 +174,58 @@
 SHUT "$daename";
 quit;
 
 EOF
 
-if [ -n "$partition" ]; then
-  rm -f mtt_junk
-  # Now for the subsystems
-  # Find subsystems
-  subsystems=`mtt_get_subsystems $1`
-
-  for subsystem in $subsystems; do
-  echo Doing $subsystem
-  ucname="MTT_"$subsystem"_uc"
-
-  Nu=`mtt_getsize -internal $subsystem"_1" u`
-  echo Nu $Nu
-
-  # Use symbolic algebra to accomplish the transformation
-  $SYMBOLIC >$logname  << EOF
-
-  %Read the formatting function
-  in "$MTTPATH/trans/reduce_matrix.r";
-
-  % Definitions
-  in "$defname";
-
-  % Elementary system equations
-  in "$rdaename";
-
-  OFF Echo;
-  OFF Nat;
- 
-  %Create the output file
-  OUT "mtt_junk";
-  % Connecting inputs
-  MTT_Matrix := $ucname $
-  MTT_Matrix_name := "$ucname" $
-  MTT_Matrix_n := $Nu $
-  MTT_Matrix_m := 1$
-  Reduce_Matrix()$
-
-  shut "mtt_junk";
-EOF
-  echo >> $1_dae.r
-  echo %Connections for subsystem $subsystem  >> $1_dae.r
-  echo >> $1_dae.r
-
-  cat mtt_junk >> $1_dae.r
-  rm -rf mtt_junk
-  done
-fi
+#if [ -n "$partition" ]; then
+#  rm -f mtt_junk
+#  # Now for the subsystems
+#  # Find subsystems
+#  subsystems=`mtt_get_subsystems $1`
+#
+#  for subsystem in $subsystems; do
+#  echo Doing $subsystem
+#  ucname="MTT_"$subsystem"_uc"
+#
+#  Nu=`mtt_getsize -internal $subsystem u`
+#  echo Nu $Nu
+#
+#  # Use symbolic algebra to accomplish the transformation
+#  $SYMBOLIC >$logname  << EOF
+#
+#  %Read the formatting function
+#  in "$MTTPATH/trans/reduce_matrix.r";
+#
+#  % Definitions
+#  in "$defname";
+#
+#  % Elementary system equations
+#  in "$rdaename";
+#
+#  OFF Echo;
+#  OFF Nat;
+# 
+#  %Create the output file
+#  OUT "mtt_junk";
+#  % Connecting inputs
+#  MTT_Matrix := $ucname $
+#  MTT_Matrix_name := "$ucname" $
+#  MTT_Matrix_n := $Nu $
+#  MTT_Matrix_m := 1$
+#  Reduce_Matrix()$
+#
+#  shut "mtt_junk";
+#EOF
+#  echo >> $1_dae.r
+#  echo %Connections for subsystem $subsystem  >> $1_dae.r
+#  echo >> $1_dae.r
+#
+#  cat mtt_junk >> $1_dae.r
+#  rm -rf mtt_junk
+#  done
+#fi
 
 echo "END;" >> $1_dae.r
 
 # Now invoke the standard error handling.
 mtt_error_r $logname
 

Index: mttroot/mtt/bin/trans/reps_txt2tk
==================================================================
--- mttroot/mtt/bin/trans/reps_txt2tk
+++ mttroot/mtt/bin/trans/reps_txt2tk
@@ -11,10 +11,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.4  2000/04/05 07:37:27  peterg
+## *** empty log message ***
+##
 ## Revision 1.3  1999/08/18 06:15:48  peterg
 ## Stripped down to just representations menu - see mtt_make_menu
 ##
 ## Revision 1.2  1999/03/09 00:03:19  peterg
 ## Revisions for xmtt
@@ -22,13 +25,14 @@
 ## Revision 1.1  1998/10/20 08:13:14  peterg
 ## Initial revision
 ##
 ###############################################################
 
+sep='|'; # Separates the languages from the rest.
 
 # Create reps menu
-awk --field-separator='|' '{
+awk --field-separator=$sep '{
   
 # Find the rep and the title
   split($1,REP," ");
   rep=REP[1];
 # find the languages
@@ -41,30 +45,24 @@
     sub(/\*/,"",$1);
     printf("\n# Menus for representation %s\n", rep)
     printf(".rep.rep add  cascade -label \"%s\" -menu .rep.rep.%s\n", $1, rep);
     printf("menu .rep.rep.%s\n", rep);
     for (i=1;i<=N;i++) {
-      printf(" set mtt {mtt $args $system %s %s} \n", rep, LANG[i]); 
-      printf(".rep.rep.%s add  command -label  \"%s\" ", rep, LANG[i]);
-      printf(" -command  \"exec echo $mtt &; exec $mtt &\" \n"); 
+      lang = LANG[i];
+      printf(" set mtt {mtt_pause $args $system %s %s} \n", rep, lang); 
+      title = sprintf("Output_log_for_representation_%s_(language_%s)", rep, lang);
+      printf(".rep.rep.%s add  command -label  \"%s\" ", rep, lang);
+      printf(" -command  \"exec xterm -title %s -e $mtt  &\" \n", title); 
    }
  }
  else {
     printf("\n# Menus for representation %s\n", rep)
     printf(".repall.repall add  cascade  -label \"%s\" -menu .repall.repall.%s\n", $1, rep);
     printf("menu .repall.repall.%s\n", rep);
     for (i=1;i<=N;i++) {
-      printf(" set mtt {mtt $args $system %s %s} \n", rep, LANG[i]); 
+      printf(" set mtt {mtt $args $system %s %s; mtt_pause} \n", rep, LANG[i]); 
       printf(".repall.repall.%s add  command -label  \"%s\" ", rep, LANG[i]);
       printf(" -command  \"exec echo $mtt &; exec $mtt &\" \n"); 
    }
  }
 }'
-
-
-
-
-
-
-
-
 

Index: mttroot/mtt/bin/trans/sm2can_r
==================================================================
--- mttroot/mtt/bin/trans/sm2can_r
+++ mttroot/mtt/bin/trans/sm2can_r
@@ -2,96 +2,371 @@
 
      ###################################### 
      ##### Model Transformation Tools #####
      ######################################
 
-# Bourne shell script: csm2sm_r
-# Constrained-state equation to linear constrained-state matrices conversion
-# P.J.Gawthrop  6th September 1991, May 1994
-# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996
+# Bourne shell script: sm2can_r
+# state matrices to various canonical forms.
+# P.J.Gawthrop  12 Jan 1997
+# Copyright (c) P.J.Gawthrop 1997
 
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
-## Revision 1.2  1996/08/25 10:11:32  peter
-## Added END in output file.
-## Error handling.
-##
-## Revision 1.1  1996/08/19 15:06:16  peter
-## Initial revision
-##
 ###############################################################
+
 
 # Inform user
-echo Creating $1_sm.r
+echo Creating $1_can.r -- NOTE this is for SISO systems only.
 
 # Remove the old log file
-rm -f csm2sm_r.log
+rm -f sm2can_r.log
 
 # Use reduce to accomplish the transformation
-reduce >csm2sm_r.log << EOF
+reduce >sm2can_r.log << EOF
 
 in "$1_def.r";
-in "$1_csm.r";
-in "$1_cr.r";
-in "$1_sympar.r";
+in "$1_sm.r";
+in "$1_tf.r";
+
+%Read the formatting function
+in "$MTTPATH/trans/reduce_matrix.r";
+
 
 OFF Echo;
 OFF Nat;
 
-% Find MTTA and MTTB : the A and B matrices
+% Find the controllability and observibility matrices.
+MATRIX MTTCon(MTTNx,MTTNX);
+MTTAB := MTTB;
+FOR j := 1:MTTNx DO
+  BEGIN
+   FOR i := 1:MTTNx DO 
+      MTTCon(i,j) := MTTAB(i,1);
+   MTTAB := MTTA*MTTAB;
+  END;
+
+MATRIX MTTObs(MTTNx,MTTNX);
+MTTCA := MTTC;
+FOR i := 1:MTTNx DO
+  BEGIN
+   FOR j := 1:MTTNx DO 
+      MTTObs(i,j) := MTTCA(1,j);
+   MTTCA := MTTCA*MTTA;
+  END;
+
+%Canonical forms:
+% This statement makes Gs a scalar transfer function
+Gs := MTTtf(1,1);
+
+% Numerator and denominator polynomials
+bs := num(gs);
+as := den(gs);
+
+% extract coeficients and divide by coeff of s^n
+% reverse operator puts list with highest oder coeffs first
+ai := reverse(coeff(as,s));
+a0 := first(ai);
+MTTn := length(ai) - 1;
+
+
+% Normalised coeficients;
+ai := reverse(coeff(as/a0,s));
+bi := reverse(coeff(bs/a0,s));
+MTTm := length(bi)-1;
+
+% Zap the (unity) first element of ai list;
+ai := rest(ai);
+
+% System in controller form
+% MTTA_c matrix
+matrix MTTA_c(MTTn,MTTn);
+
+% First row is ai coefficients
+for i := 1:MTTn do
+  MTTA_c(1,i) := -part(ai,i);
+
+% (MTTn-1)x(MTTn-1) unit matrix in lower left-land corner (if n>1)
+if MTTn>1 then
+  for i := 1:MTTn-1 do
+    MTTA_c(i+1,i) := 1;
+
+% B_c vector;
+matrix MTTB_c(MTTn,1);
+MTTB_c(1,1) := 1;
+
+% C_c vector;
+matrix MTTC_c(1,MTTn);
+for i := 1:MTTm+1 do
+  MTTC_c(1,i+MTTn-MTTm-1) := part(bi,i);
+
+% D_c
+MTTD_c := MTTD;
+
+%Observable form.
+MTTA_o := tp(MTTA_c);
+MTTB_o := tp(MTTC_c);
+MTTC_o := tp(MTTB_c);
+MTTD_o := MTTD;
+
+%Controllability matrix of controllable form
+MATRIX MTTCon_c(MTTNx,MTTNX);
+MTTAB := MTTB_c;
+FOR j := 1:MTTNx DO
+  BEGIN
+   FOR i := 1:MTTNx DO 
+      MTTCon_c(i,j) := MTTAB(i,1);
+   MTTAB := MTTA_c*MTTAB;
+  END;
+
+% Transformation matrix;
+MTTT_c := MTTCon_c*MTTCon^(-1);
+
+%Observability matrix of observer form
+MATRIX MTTObs_o(MTTNx,MTTNX);
+MTTCA := MTTC_o;
+FOR i := 1:MTTNx DO
+  BEGIN
+   FOR j := 1:MTTNx DO 
+      MTTObs_o(i,j) := MTTCA(1,j);
+   MTTCA := MTTCA*MTTA_o;
+  END;
+
+% Transformation matrix;
+MTTT_o := MTTObs^(-1)*MTTObs_o;
+
+%%%%  Controller design %%%%%
+
+% gain in controller form:
+matrix MTTk_c(1,mttn);
+matrix alpha_c(9,1);
+alpha_c(1,1) := alpha_c1;
+alpha_c(2,1) := alpha_c2;
+alpha_c(3,1) := alpha_c3;
+alpha_c(4,1) := alpha_c4;
+alpha_c(5,1) := alpha_c5;
+alpha_c(6,1) := alpha_c6;
+alpha_c(7,1) := alpha_c7;
+alpha_c(8,1) := alpha_c8;
+alpha_c(9,1) := alpha_c9;
+
+
+for i := 1:MTTNx do
+ MTTk_c(1,i) := alpha_c(i,1) - part(ai,i);
+
+% Gain in physical form
+MTTk := MTTk_c*MTTT_c;
+
+%%%%  Observer design %%%%%
+% gain in Observer form:
+matrix MTTl_o(MTTn,1);
+matrix alpha_o(9,1);
+alpha_o(1,1) := alpha_o1;
+alpha_o(2,1) := alpha_o2;
+alpha_o(3,1) := alpha_o3;
+alpha_o(4,1) := alpha_o4;
+alpha_o(5,1) := alpha_o5;
+alpha_o(6,1) := alpha_o6;
+alpha_o(7,1) := alpha_o7;
+alpha_o(8,1) := alpha_o8;
+alpha_o(9,1) := alpha_o9;
+
+for i := 1:MTTNx DO
+ MTTL_o(i,1) := alpha_o(i,1) - part(ai,i);
+
+% Gain in physical form
+MTTL := MTTT_o*MTTL_o;
+
+% Steady-state stuff
+% Create the matrix [A B; C D];
+matrix ABCD(MTTn+1,MTTn+1);
+for i := 1:MTTNx do
+  for j := 1:MTTNx do
+    ABCD(i,j) := MTTA(i,j);
+
+for i :=1:MTTNx do
+  ABCD(i,MTTNx+1) := MTTB(i,1);
+
+for j := 1:MTTNx do
+  ABCD(MTTNx+1,j) := MTTC(1,j);
+
+ABCD(MTTNx+1,MTTNx+1) := MTTD(1,1);
+
+matrix zero_one(MTTNx+1,1);
+zero_one(MTTNx+1,1) := 1;
+
+%Find N vector
+Nxu := ABCD^(-1)*zero_one;
+
+%Extract the parts
+MATRIX MTTX_r(MTTNx,1);
+FOR i := 1:MTTNx DO
+  MTTX_r(i,1) := Nxu(i,1);
+
+MTTu_r := Nxu(MTTNx+1,1);
+
+
+% Compensator
 
-MTTinvE := MTTE^(-1);
-MTTA := MTTinvE*MTTA;
-MTTB := MTTinvE*MTTB;
+matrix zero(MTTNx,1);
+%State matrices
+MTTA_comp := MTTA - MTTL*MTTC - MTTB*MTTK;
+MTTB_comp := -MTTL;
+MTTC_comp := -MTTK;
 
+%Transfer function
+%Ds := C_d*((s*MTTI - A_d)^(-1))*B_d;
+%MTTTFC := Ds;
 
 %Create the output file
-OUT "$1_sm.r";
+OUT "$1_can.r";
 
 %Write out the matrices.
-IF MTTNx>0 THEN
-BEGIN
-  write "matrix MTTA(", MTTNx, ",", MTTNx, ");";
-  FOR i := 1:MTTNx DO
-   FOR j := 1:MTTNx DO IF MTTA(i,j) NEQ 0 THEN
-      write "MTTA(", i, ",", j, ") := ", MTTA(i,j);
-END;
-
-IF MTTNx>0 THEN
-IF MTTNu>0 THEN
-BEGIN
-  write "matrix MTTB(", MTTNx, ",", MTTNu, ");";
-  FOR i := 1:MTTNx DO
-   FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN
-      write "MTTB(", i, ",", j, ") := ", MTTB(i,j);
-END;
-
-%Write it out
-IF MTTNy>0 THEN
-IF MTTNx>0 THEN
-BEGIN
-  write "matrix MTTC(", MTTNy, ",", MTTNx, ");";
-  FOR i := 1:MTTNy DO
-    FOR j := 1:MTTNx DO IF MTTC(i,j) NEQ 0 THEN
-      write "MTTC(", i, ",", j, ") := ", MTTC(i,j);
-END;
-
-IF MTTNy>0 THEN IF MTTNu>0 THEN 
-BEGIN
-  write "matrix MTTD(", MTTNy, ",", MTTNu, ");";
-  FOR i := 1:MTTNy DO
-    FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN
-      write "MTTD(", i, ",", j, ") := ", MTTD(i,j);
-END;
-
+
+% Controllable form
+MTT_Matrix := MTTA_c$ 
+MTT_Matrix_name := "MTTA_c"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+MTT_Matrix := MTTB_c$ 
+MTT_Matrix_name := "MTTB_c"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNu$
+Reduce_Matrix()$
+
+MTT_Matrix := MTTC_c$ 
+MTT_Matrix_name := "MTTC_c"$
+MTT_Matrix_n := MTTNy$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+
+% Observable form
+MTT_Matrix := MTTA_o$ 
+MTT_Matrix_name := "MTTA_o"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+MTT_Matrix := MTTB_o$ 
+MTT_Matrix_name := "MTTB_o"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNu$
+Reduce_Matrix()$
+
+MTT_Matrix := MTTC_o$ 
+MTT_Matrix_name := "MTTC_o"$
+MTT_Matrix_n := MTTNy$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  - Controllability matrix";
+MTT_Matrix := MTTCon$ 
+MTT_Matrix_name := "MTTCon"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  -Observability matrix";
+MTT_Matrix := MTTObs$ 
+MTT_Matrix_name := "MTTObs"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  -Controllability matrix - controller form";
+MTT_Matrix := MTTCon_c$ 
+MTT_Matrix_name := "MTTCon_c"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  - Transformation matrix - controller form";
+MTT_Matrix := MTTT_c$ 
+MTT_Matrix_name := "MTTT_c"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  - Gain matrix - controller form";
+MTT_Matrix := MTTK_c$ 
+MTT_Matrix_name := "MTTK_c"$
+MTT_Matrix_n := MTTNu$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  - Gain matrix - physical form";
+MTT_Matrix := MTTK$ 
+MTT_Matrix_name := "MTTK"$
+MTT_Matrix_n := MTTNu$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+
+write "%  -Observability matrix - Observer form";
+MTT_Matrix := MTTObs_o$ 
+MTT_Matrix_name := "MTTObs_o"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  - Transformation matrix - Observer form";
+MTT_Matrix := MTTT_o$ 
+MTT_Matrix_name := "MTTT_o"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+write "%  - Observer Gain matrix - observer form";
+MTT_Matrix := MTTL_o$ 
+MTT_Matrix_name := "MTTL_o"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNy$
+Reduce_Matrix()$
+
+write "%  - Gain matrix - physical form";
+MTT_Matrix := MTTL$ 
+MTT_Matrix_name := "MTTL"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNy$
+Reduce_Matrix()$
+
+
+% Controllable form
+MTT_Matrix := MTTA_comp$ 
+MTT_Matrix_name := "MTTA_comp"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+MTT_Matrix := MTTB_comp$ 
+MTT_Matrix_name := "MTTB_comp"$
+MTT_Matrix_n := MTTNx$
+MTT_Matrix_m := MTTNu$
+Reduce_Matrix()$
+
+MTT_Matrix := MTTC_comp$ 
+MTT_Matrix_name := "MTTC_comp"$
+MTT_Matrix_n := MTTNy$
+MTT_Matrix_m := MTTNx$
+Reduce_Matrix()$
+
+
+KX := MTTK*MTTX_r;
+MTTu_r := MTTu_r + KX(1,1);
+
+
+
+MTTu_r := MTTu_r;
 write "END;";
 
-SHUT "$1_sm.r";
+SHUT "$1_can.r";
 quit;
 
 EOF
 
 # Now invoke the standard error handling.
-mtt_error_r csm2sm_r.log
+mtt_error_r sm2can_r.log

Index: mttroot/mtt/bin/trans/sm2ir_m
==================================================================
--- mttroot/mtt/bin/trans/sm2ir_m
+++ mttroot/mtt/bin/trans/sm2ir_m
@@ -17,24 +17,24 @@
 rm -f sm2ir_m.log
 rm -f $1_ir.m
 rm -f $1_iro.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
+# 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 > sm2ir_m.log 2>mtt_error.txt
 
   % Read in the numeric system parameters
-  $1_numpar;
+  mttpar = $1_numpar;
 
   [nx,ny,nu,nz,nyz] = $1_def;
   t=0;	%Just in case it appears in the parameter list.
 
   $PARAMS
@@ -56,11 +56,11 @@
   [n,m]=size(T);
   if m>n
     T=T';
   end;
 
-  [A,B,C,D] = $1_sm;
+  [A,B,C,D] = $1_sm(mttpar);
   [y,x] = sm2ir(A,B,C,D,T,u0,x0);
 
   if nx>0
     write_matrix([T x], '$1_ir');
   end;

Index: mttroot/mtt/bin/trans/smc2ssk_r
==================================================================
--- mttroot/mtt/bin/trans/smc2ssk_r
+++ mttroot/mtt/bin/trans/smc2ssk_r
@@ -12,22 +12,41 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.3  1998/02/09 14:16:52  peterg
+## Writes end statement to the o/p file
+##
 ## Revision 1.2  1998/01/23 09:30:36  peterg
 ## Fixed a sign error - the coeficients of a(s) appear with - signs in
 ## the A_c matrix!
 ##
 ## Revision 1.1  1998/01/22 13:16:16  peterg
 ## Initial revision
 ##
 ###############################################################
 
+Nu=`mtt_getsize $1 u`
+Ny=`mtt_getsize $1 y`
+
+if [ "$Nu" = "1" ]; then
+  if [ "$Ny" = "1" ]; then
+    blurb=' for this siso system'    
+  else
+    blurb=" using first output of $Ny"
+  fi
+else
+  if [ "$Ny" = "1" ]; then
+    blurb=" using first input of $Nu"
+  else
+    blurb=" using first input of $Nu and using first output of $Ny"
+  fi
+fi
 
 # Inform user
-echo Creating $1_ssk.r -- NOTE this is for SISO systems only.
+echo Creating $1_ssk.r $blurb
 
 # Remove the old log file
 rm -f smc2ssk_r.log
 
 # Use reduce to accomplish the transformation
@@ -74,18 +93,18 @@
 %Write out the matrices.
 
 write "%  - Gain matrix - controller form";
 MTT_Matrix := MTTK_c$ 
 MTT_Matrix_name := "MTTK_c"$
-MTT_Matrix_n := MTTNu$
+MTT_Matrix_n := 1$
 MTT_Matrix_m := MTTNx$
 Reduce_Matrix()$
 
 write "%  - Gain matrix - physical form";
 MTT_Matrix := MTTK$ 
 MTT_Matrix_name := "MTTK"$
-MTT_Matrix_n := MTTNu$
+MTT_Matrix_n := 1$
 MTT_Matrix_m := MTTNx$
 Reduce_Matrix()$
 
 write "END;";
 

Index: mttroot/mtt/bin/trans/ssk2ctf_r
==================================================================
--- mttroot/mtt/bin/trans/ssk2ctf_r
+++ mttroot/mtt/bin/trans/ssk2ctf_r
@@ -11,10 +11,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.2  1998/02/09 14:04:00  peterg
+## Renamed matrix to cTF;
+##
 ## Revision 1.1  1998/02/09 13:54:34  peterg
 ## Initial revision
 ##
 ###############################################################
 
@@ -47,11 +50,11 @@
 B_d := -MTTL;
 C_d := -MTTK;
 D_d := 0;
 
 %Transfer function
-MTTGc := C_d*((s*MTTI - A_d)^(-1))*B_d;
+MTTcTF := C_d*((s*MTTI - A_d)^(-1))*B_d;
 
 %Create the output file
 OUT "$1_ctf.r"; 
 %Write out the matrices.
 

Index: mttroot/mtt/bin/trans/struc_txt2tex
==================================================================
--- mttroot/mtt/bin/trans/struc_txt2tex
+++ mttroot/mtt/bin/trans/struc_txt2tex
@@ -13,10 +13,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+# Revision 1.3  1997/12/06  19:10:41  peterg
+# Reverted to tabular --- from supertabular
+#
 # Revision 1.2  1997/04/15  11:17:58  peterg
 # Uses supertabular for long tables.
 #
 # Revision 1.1  1997/04/15  09:49:04  peterg
 # Initial revision
@@ -31,40 +34,42 @@
 
 #Write some file headers
 echo "%% Structure file ($1_struc.txt)" > $1_struc.tex
 echo "%% Generated by MTT at `date`" >> $1_struc.tex
 
-# This is the main transformation using gawk
-sed 's/_/\\_/g' < $1_struc.txt |  gawk '
-#function header(what){
-#  print "  \\centering";
-# print "  \\tablefirsthead{\\hline %";
-#  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM "} \\\\";
-#  print "    \\hline";
-#  print "     & Component & System & Repetition \\\\";
-#  print "    \\hline}";
-#
-#  print "  \\tablehead{\\hline %";
-#  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM " (continued)} \\\\";
-#  print "    \\hline";
-#  print "     & Component & System & Repetition \\\\";
-#  print "    \\hline}";
-#
-#  print "  \\tabletail{\\hline}";
-#  print "  \\begin{supertabular}{|l|l|l|l|}";
-#}
-function header(what){
-  print "\\begin{table}[htbp]";
-  print "  \\begin{tabular}{|l|l|l|l|}";  print "    \\hline";
-  print "     & Component & System & Repetition \\\\";
-  print "    \\hline";
-}
+# This is the main transformation using awk
+sed 's/_/\\_/g' < $1_struc.txt |  awk '
+function header(what){
+  print "  \\centering";
+ print "  \\tablefirsthead{\\hline %";
+  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM "} \\\\";
+  print "    \\hline";
+  print "     & Component & System & Repetition \\\\";
+  print "    \\hline}";
+
+  print "  \\tablehead{\\hline %";
+  print "    \\multicolumn{4}{|c|}{\\bf List of " what "s for system " SYSTEM " (continued)} \\\\";
+  print "    \\hline";
+  print "     & Component & System & Repetition \\\\";
+  print "    \\hline}";
+
+  print "  \\tabletail{\\hline}";
+  print "  \\begin{supertabular}{|l|l|l|l|}";
+}
+#function header(what){
+#  print "\\begin{table}[htbp]";
+#  print "  \\centering";
+#  print "  \\begin{tabular}{|l|l|l|l|}";  print "    \\hline";
+#  print "     & Component & System & Repetition \\\\";
+#  print "    \\hline";
+#}
 function footer(what){
   print "    \\hline";
-  print "  \\end{tabular}";
+  print "  \\end{supertabular}";
+#  print "  \\end{tabular}";
 #  print "  \\caption{" what "}";
-  print "\\end{table}";
+#  print "\\end{table}";
   print "   \\bigskip";
   print "   \\bigskip";
 }
 
 BEGIN{

Index: mttroot/mtt/bin/trans/sub2subs
==================================================================
--- mttroot/mtt/bin/trans/sub2subs
+++ mttroot/mtt/bin/trans/sub2subs
@@ -12,11 +12,13 @@
 
 # echo the name of the subsystems one level down
 sh $1\_sub.sh "echo  " 
 
 # Create the corresponding subsystems --  quietly!
-(sh $1\_sub.sh "mtt -q   " " sub sh") >/dev/null
+#(sh $1\_sub.sh "mtt -q  " " sub sh") #>/dev/null
+(sh $1\_sub.sh " cmp2sub_m2sh  " " ") >/dev/null
+
 
 # Recursively execute the subsystem files
 sh $1\_sub.sh "sub2subs " 
 
 

Index: mttroot/mtt/bin/trans/tex2doc
==================================================================
--- mttroot/mtt/bin/trans/tex2doc
+++ mttroot/mtt/bin/trans/tex2doc
@@ -13,16 +13,20 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+# Revision 1.2  1996/08/30  10:19:11  peter
+# New path for awk script.
+#
 ## Revision 1.1  1996/08/18 20:00:20  peter
 ## Initial revision
 ##
 ###############################################################
 
 # Inform user
 echo "Creating $1_$2.doc"
 
-# This is the main transformation using gawk
-gawk -f $MTTPATH/trans/awk/tex2doc.awk $1_$2.txt  > $1_$2.doc
+# This is the main transformation using awk
+awk -f $MTTPATH/trans/awk/tex2doc.awk \
+system_name=$1 representation=$2  > $1_$2.doc