Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -17,10 +17,13 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.14 1996/08/16 14:52:24 peter +## Added two alternative view options - dview and pview. +## ## Revision 1.13 1996/08/16 08:24:31 peter ## Correctly chooses how to make a ps file using $REPTYPE. ## ## Revision 1.12 1996/08/15 16:47:47 peter ## DAE solution (experimental) included. @@ -125,15 +128,25 @@ case $2 in abg ) REPTYPE='bg' ;; cbg ) REPTYPE='bg' ;; - odesol) + odes) + REPTYPE='data' ;; + odeso) + REPTYPE='data' ;; + odess) + REPTYPE='data' ;; + odesso) + REPTYPE='data' ;; + daes) REPTYPE='data' ;; - daesol) + daeso) REPTYPE='data' ;; sr) + REPTYPE='data' ;; + sro) REPTYPE='data' ;; lmfr) REPTYPE='data' ;; lpfr) REPTYPE='data' ;; @@ -242,11 +255,11 @@ #Elementary system equations + definitions $1_ese.r: $1_cbg.m cbg2ese_m2r $1 $1_def.r: $1_ese.r - touch $1_ese.r + touch $1_def.r $1_def.m: $1_def.r def_r2m $1; matlab_tidy $1_def.m; #Differential-algebraic equations @@ -326,14 +339,28 @@ #Time responses $1_sr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m dm2sr_m $1 '$ARGS' -$1_odesol.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m - ode2odesol_m $1 '$ARGS' -$1_daesol.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m $1_input.m - dae2daesol_m $1 '$ARGS' +$1_sro.m: $1_sr.m + touch $1_sro.m +$1_odes.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m + ode2odes_m $1 '$ARGS' +$1_odeso.m: $1_odes.m + touch $1_odeso.m +$1_daes.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m $1_input.m + dae2daes_m $1 '$ARGS' +$1_daeso.m: $1_daes.m + touch $1_daeso.m + +#Numerical steady states +$1_odess.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m + ode2odess_m $1 '$ARGS' + +$1_odesso.m: $1_odess.m + touch $1_odesso.m + #Frequency responses $1_fr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m dm2fr_m $1 '$ARGS' $1_lmfr.m: $1_fr.m @@ -387,13 +414,21 @@ echo Creating $1_$2.ps dvips -o $1_$2.ps $1_$2 endif #Default view -$1_$2.view: $1_$2.ps - echo Creating view of $1_$2 - ghostview $1_$2.ps& +ifeq ($REPTYPE,bg) +$1_$2.view : $1_$2.pview +endif + +ifeq ($REPTYPE,data) +$1_$2.view : $1_$2.dview +endif + +ifeq ($REPTYPE,tex) +$1_$2.view : $1_$2.tview +endif #View a ps file $1_$2.pview: $1_$2.ps echo Creating view of $1_$2 ghostview $1_$2.ps& @@ -400,10 +435,15 @@ #View a gdat file $1_$2.dview: $1_$2.gdat echo Creating view of $1_$2 gdat2view $1_$2 '$ARGS'& + +#View a tex file +$1_$2.tview: $1_$2.dvi + echo Creating view of $1_$2 + xdvi $1_$2.dvi& #Report generation $1_rep.tex: $1_sum.tex $1_dae.tex $1_lbl.txt $1_sympar.r $1_cr.r \ $1_abg.ps Index: mttroot/mtt/bin/trans/m/dm2sr.m ================================================================== --- mttroot/mtt/bin/trans/m/dm2sr.m +++ mttroot/mtt/bin/trans/m/dm2sr.m @@ -1,17 +1,21 @@ -function sr = dm2sr(A,B,C,D,E,T,u0,x0); -% sr = dm2sr(A,B,C,D,E,T); +function [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0); +% [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0); % Descriptor matrix to impulse response. % NB At the moment - this assumes that E is unity ..... % A,B,C,D,E - descriptor matrices % T vector of time points +% u0 input gain vector: u = u0*unit step. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.4 1996/08/15 08:34:08 peter +% %% Added step gain (u0) and initial condition (x0) +% %% % %% Revision 1.3 1996/08/11 19:33:24 peter % %% Replaced exp by expm - whoops! % %% % %% Revision 1.2 1996/08/11 10:37:40 peter % %% Corrected mistake in step-response calculation. @@ -39,14 +43,24 @@ N = M; end; one = eye(Nx); -sr = zeros(N,Ny); +Y = zeros(N,Ny); +X = zeros(N,Nx); i = 0; for t = T' i=i+1; - expAt = expm(A*t); - SR = C*( ( A\(expAt-one) )*B*u0 + expAt*x0) + D*u0; - sr(i,:) =SR'; + if Nx>0 + expAt = expm(A*t); + x = ( A\(expAt-one) )*B*u0 + expAt*x0; + X(i,:) = x'; + if Ny>0 + y = C*x + D*u0; + Y(i,:) = y'; + end; + elseif Ny>0 + y = D*u0; + Y(i,:) = y'; + end; end; Index: mttroot/mtt/bin/trans/ode2odes_m ================================================================== --- mttroot/mtt/bin/trans/ode2odes_m +++ mttroot/mtt/bin/trans/ode2odes_m @@ -2,11 +2,11 @@ ###################################### ##### Model Transformation Tools ##### ###################################### -# Bourne shell script: ode2odesol_m +# Bourne shell script: ode2odes_m # Transforms descriptor matrix rep to step response # Copyright (c) P.J.Gawthrop, 1996. @@ -13,10 +13,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.4 1996/08/16 13:04:46 peter +## Fixed problem with more than one output (y vector). +## ## Revision 1.3 1996/08/16 06:36:03 peter ## Removed u from default arg list. ## ## Revision 1.2 1996/08/15 16:24:43 peter ## Uses T in place of t to avoid name clash within function. @@ -24,12 +27,12 @@ ## Revision 1.1 1996/08/15 11:56:38 peter ## Initial revision ## ############################################################### -echo Creating $1_odesol.m -rm -f ode2odesol_m.log +echo Creating $1_odes.m +rm -f ode2odes_m.log if [ "$2" = "" ]; then PARAMS='T=[0:0.1:10]; x0=zeros(nx,1);' echo Using default parameter $PARAMS @@ -38,11 +41,11 @@ fi PARAMS="$PARAMS ;" -$MATRIX << EOF > ode2odesol_m.log +$MATRIX << EOF > ode2odes_m.log [nx,ny,nu,nz,nyz] = $1_def; t=0; %Just in case it appears in the parameter list. $PARAMS @@ -59,22 +62,28 @@ [n,m]=size(T); if m>n T=T'; end; -x = lsode('$1_ode', x0, T); - -i=0; -for tt=T' - i=i+1; - y(i,:) = $1_odeo(x(i,:),tt)'; +if nx>0 + x = lsode('$1_ode', x0, T); + write_matrix([T,x], '$1_odes'); +else + x = zeros(size(T)); end; -write_matrix([T,y], '$1_odesol'); +if ny>0 + i=0; + for tt=T' + i=i+1; + y(i,:) = $1_odeo(x(i,:),tt)'; + end; + write_matrix([T,y], '$1_odeso'); +end; EOF Index: mttroot/mtt/bin/trans/sm2sr_m ================================================================== --- mttroot/mtt/bin/trans/sm2sr_m +++ mttroot/mtt/bin/trans/sm2sr_m @@ -14,10 +14,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## 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 @@ -39,11 +42,14 @@ ## Initial revision ## ############################################################### echo Creating $1_sr.m +echo Creating $1_sro.m rm -f dm2sr_m.log +rm -f $1_sr.m +rm -f $1_sro.m if [ "$2" = "" ]; then PARAMS='T=[0:0.1:10];u0=ones(nu,1);x0=zeros(nx,1);' echo Using default parameter $PARAMS @@ -78,11 +84,16 @@ if m>n T=T'; end; [A,B,C,D,E] = $1_dm($1_numpar); - y = dm2sr(A,B,C,D,E,T,u0,x0); + [y,x] = dm2sr(A,B,C,D,E,T,u0,x0); - write_matrix([T y], '$1_sr'); + if nx>0 + write_matrix([T x], '$1_sr'); + end; + if ny>0 + write_matrix([T y], '$1_sro'); + end; EOF