ADDED mttroot/mtt/lib/rep/ident_rep.make Index: mttroot/mtt/lib/rep/ident_rep.make ================================================================== --- /dev/null +++ mttroot/mtt/lib/rep/ident_rep.make @@ -0,0 +1,101 @@ +# -*-makefile-*- +# Makefile for representation ident +# File ident_rep.make + +#Copyright (C) 2000,2001,2002 by Peter J. Gawthrop + +## Model targets +model_reps = ${SYS}_sympar.m ${SYS}_simpar.m ${SYS}_state.m +model_reps += ${SYS}_numpar.m ${SYS}_input.m ${SYS}_ode2odes.m +model_reps += ${SYS}_def.m + +## Prepend s to get the sensitivity targets +sensitivity_reps = ${model_reps:%=s%} + +## Simulation targets +sims = ${SYS}_sim.m s${SYS}_ssim.m + +## m-files needed for ident +ident_m = ${SYS}_ident.m ${SYS}_ident_numpar.m + +## Targets for the ident simulation +ident_reps = ${ident_m} ${sims} ${model_reps} ${sensitivity_reps} + +## ps output files +psfiles = ${SYS}_ident.ps ${SYS}_ident.basis.ps ${SYS}_ident.par.ps ${SYS}_ident.U.ps +figfiles = ${psfiles:%.ps=%.fig} + +all: ${SYS}_ident.${LANG} + +echo: + echo "sims: ${sims}" + echo "model_reps: ${model_reps}" + echo "sensitivity_reps: ${sensitivity_reps}" + echo "ident_reps: ${ident_reps}" + +${SYS}_ident.view: ${SYS}_ident.ps + ident_rep.sh ${SYS} view + +${psfiles}: ${SYS}_ident.fig + ident_rep.sh ${SYS} ps + +${SYS}_ident.gdat: ${SYS}_ident.dat2 + ident_rep.sh ${SYS} gdat + +${SYS}_ident.fig ${SYS}_ident.dat2: ${ident_reps} + ident_rep.sh ${SYS} dat2 + +${SYS}_ident.m: + ident_rep.sh ${SYS} m + +${SYS}_ident_numpar.m: + ident_rep.sh ${SYS} numpar.m + +## System model reps +## Generic txt files +${SYS}_%.txt: + mtt ${OPTS} -q -stdin ${SYS} $* txt + +## Specific m files +${SYS}_ode2odes.m: ${SYS}_rdae.r + mtt -q -stdin ${OPTS} ${SYS} ode2odes m + +${SYS}_sim.m: ${SYS}_ode2odes.m + mtt ${OPTS} -q -stdin ${SYS} sim m + +## Generic txt to m +${SYS}_%.m: ${SYS}_%.txt + mtt ${OPTS} -q -stdin ${SYS} $* m + +## r files +${SYS}_def.r: ${SYS}_abg.fig + mtt ${OPTS} -q -stdin ${SYS} def r + +${SYS}_rdae.r: + mtt ${OPTS} -q -stdin ${SYS} rdae r + +## Sensitivity model reps +## Generic txt files +s${SYS}_%.txt: + mtt ${OPTS} -q -stdin -s s${SYS} $* txt + +## Specific m files +s${SYS}_ode2odes.m: s${SYS}_rdae.r + mtt -q -stdin ${OPTS} -s s${SYS} ode2odes m + +s${SYS}_ssim.m: + mtt -q -stdin ${OPTS} -s s${SYS} ssim m + +s${SYS}_def.m: + mtt -q -stdin ${OPTS} -s s${SYS} def m + + +## Generic txt to m +s${SYS}_%.m: s${SYS}_%.txt + mtt ${OPTS} -q -stdin s${SYS} $* m + +## r files +s${SYS}_rdae.r: + mtt ${OPTS} -q -stdin -s s${SYS} rdae r + + ADDED mttroot/mtt/lib/rep/ident_rep.sh Index: mttroot/mtt/lib/rep/ident_rep.sh ================================================================== --- /dev/null +++ mttroot/mtt/lib/rep/ident_rep.sh @@ -0,0 +1,331 @@ +#! /bin/sh + +## ident_rep.sh +## DIY representation "ident" for mtt +# Copyright (C) 2002 by Peter J. Gawthrop + +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 +echo Creating ${filename} + +cat > ${filename} <0 + P = P(1:n-1,:); # Loose last point + PP = []; + for j=1:m + pp = [P(:,j) P(:,j)]'; + PP = [PP pp(:)]; + endfor + + oneplot; + gset output "${sys}_ident.par.fig" + title(""); + xlabel("Time (s)"); + ylabel("Parameters"); + plot(TT,PP); + endif + + [n,m] = size(U); + if m>0 oneplot; + gset output "${sys}_ident.U.fig" + title(""); + xlabel("Time (s)"); + ylabel("U"); + [n,m] = size(U); + U = U(1:n-1,:); # Loose last point + UU = []; + for j=1:m + uu = [U(:,j) U(:,j)]'; + UU = [UU uu(:)]; + endfor + plot(TT,UU); + endif + +endfunction + +EOF +} + +make_ident_numpar() { +echo Creating ${ident_numpar_file} +cat > ${sys}_ident_numpar.m < ${fig}.ps + 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 + +