#! /bin/sh

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

# Bourne shell script: def_r2m
# transforms definitions from reduce to m file.
# Copyright (c) P.J.Gawthrop 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

#Inform user
echo Creating $1_def.m

# Remove the old log file
rm -f def_r2m.log

# Use reduce to accomplish the transformation
reduce >def_r2m.log << EOF

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab

%Read in the definitions file
IN "$1_def.r";

OUT "$1_def.m";

%Headings - M-File style
%(Note. The ;; are deleted by for2mat)

write "function [nx,ny,nu,nz,nyz] = $1_def;;";
write "% [nx,ny,nu,nz,nv] = $1_def;;";
write "% Linearised descriptor matrices for system $1";
write "% File $1_def.m";
write "% Generated by MTT";

write "";
write "nx = ", MTTNx, ";";
write "ny = ", MTTNy, ";";
write "nu = ", MTTNu, ";";
write "nz = ", MTTNz, ";";
write "nyz = ", MTTNyz, ";";

SHUT "$1_def.m";

