Index: mttroot/mtt/doc/mtt.texi ================================================================== --- mttroot/mtt/doc/mtt.texi +++ mttroot/mtt/doc/mtt.texi @@ -14,10 +14,13 @@ @comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @comment Version control history @comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @comment $Id$ @comment $Log$ +@comment Revision 1.12 2002/09/19 08:09:31 gawthrop +@comment Updated documentation documentation +@comment @comment Revision 1.11 2002/08/20 15:51:17 gawthrop @comment Update to work with ident DIY rep @comment @comment Revision 1.10 2002/07/22 10:45:22 geraint @comment Fixed gnuplot rep so that it correctly re-runs the simulation if input files have changed. @@ -4590,10 +4593,13 @@ # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% Version control history # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% $Id$ # %% $Log$ +# %% Revision 1.12 2002/09/19 08:09:31 gawthrop +# %% Updated documentation documentation +# %% # %% Revision 1.11 2002/08/20 15:51:17 gawthrop # %% Update to work with ident DIY rep # %% # %% Revision 1.10 2002/07/22 10:45:22 geraint # %% Fixed gnuplot rep so that it correctly re-runs the simulation if input files have changed. @@ -5750,10 +5756,292 @@ The following example shows this in the context of the DIY representation `ident' used as an example in the previous section (@pxref{Makefile (DIY representations)}). +@verbatim +#! /bin/sh + +## ident_rep.sh +## DIY representation "ident" for mtt +# Copyright (C) 2002 by Peter J. Gawthrop + +ps=ps + +sys=$1 +rep=ident +lang=$2 +mtt_parameters=$3 +rep_parameters=$4 + +## Some names +target=${sys}_${rep}.${lang} +def_file=${sys}_def.r +dat2_file=${sys}_ident.dat2 +dat2s_file=${sys}_idents.dat2 +ident_numpar_file=${sys}_ident_numpar.m +option_file=${sys}_ident_mtt_options.txt + +## Get system information +if [ -f "${def_file}" ]; then + echo Using ${def_file} +else + mtt -q ${sys} def r +fi + +ny=`mtt_getsize $1 y` +nu=`mtt_getsize $1 u` + +check_new_options() { + if [ -f "${option_file}" ]; then + old_options=`cat ${option_file}` + if [ "${mtt_options}" != "${old_options}" ]; then + echo ${mtt_options} > ${option_file} + fi + else + echo ${mtt_options} > ${option_file} + fi +} + +## Make the _ident.m file +make_ident() { +filename=${sys}_${rep}.m +date=`date` +echo Creating ${filename} + +cat > ${filename} < ${sys}_ident_numpar.m <0) + par = ${sys}_numpar(); + x_0 = ${sys}_state(par); + dt = t(2)-t(1); + simpars.dt = dt; + simpars.last = t(length(t)); + y = ${sys}_sim(zeros(n_x,1), par, simpars, u); + endif + + ## Default parameter names - Put in your own here + sympar = ${sys}_sympar; # Symbolic params as structure + par_names = struct_elements (sympar); # Symbolic params as strings + [n,m] = size(par_names); # Size the string list + + ## Sort by index + for [i,name] = sympar + par_names(i,:) = sprintf("%s%s",name, blanks(m-length(name))); + endfor + + ## Output weighting vector + Q = ones(n_y,1); + + ## Extra parameters + extras.criterion = 1e-5; + extras.emulate_timing = 0; + extras.max_iterations = 10; + extras.simulate = simulate; + extras.v = 1e-2; + extras.verbose = 1; + extras.visual = 1; + +endfunction +EOF +} + +make_dat2() { + +## Inform user +echo Creating ${dat2_file} + +## Use octave to generate the data +octave -q < mtt_junk +sed -e "s/_\([a-z0-9,]*\)/_{\1}/g" < mtt_junk >${sys}_ident_par.tex +rm mtt_junk +} + +case ${lang} in + numpar.m) + ## Make the numpar stuff + make_ident_numpar; + ;; + m) + ## Make the code + make_ident; + ;; + dat2) + ## The dat2 language (output data) & fig file + make_dat2; + ;; + gdat) + cp ${dat2_file} ${dat2s_file} + dat22dat ${sys} ${rep} + dat2gdat ${sys} ${rep} + ;; + fig) + gdat2fig ${sys}_${rep} + ;; + ps) + figs=`ls ${sys}_ident*.fig | sed -e 's/\.fig//'` + for fig in ${figs}; do + fig2dev -Leps ${fig}.fig > ${fig}.ps + done + texs=`ls ${sys}_ident*.tex | sed -e 's/\.tex//'` + for tex in ${texs}; do + makedoc "" "${sys}" "ident_par" "tex" "" "" "$ps" + doc2$ps ${sys}_ident_par "$documenttype" + done + ;; + view) + pss=`ls ${sys}_ident*.ps` + echo Viewing ${pss} + for ps in ${pss}; do + gv ${ps}& + done + ;; + *) + echo Language ${lang} not supported by ${rep} representation + exit 3 +esac + + + +@end verbatim + @node Documentation (DIY representations), , Shell-script (DIY representations), New (DIY) representations @comment node-name, next, previous, up @subsection Documentation @cindex New representations @cindex DIY representations