ADDED mttroot/mtt/bin/trans/m/dm2sr.m Index: mttroot/mtt/bin/trans/m/dm2sr.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/dm2sr.m @@ -0,0 +1,34 @@ +function sr = dm2sr(A,B,C,D,E,T); +% sr = dm2sr(A,B,C,D,E,T); +% 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 + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +[N,M] = size(T); +if M>N + T = T'; + N = M; +end; + +[Ny,Nu] = size(D); +NN=Ny*Nu; + +[N_y,N_x] = size(C); +one = eye(N_x); + +sr = zeros(N,NN); +i = 0; +for t = T' + i=i+1; + sr(i,:) = reshape(C*(1-exp(A*t))*B + D*ones(size(t)), 1,NN); +end; + ADDED mttroot/mtt/bin/trans/sm2sr_m Index: mttroot/mtt/bin/trans/sm2sr_m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/sm2sr_m @@ -0,0 +1,40 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: dm2sr + +# Transforms descriptor matrix rep to step response + + +# Copyright (c) P.J.Gawthrop, 1996. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + +echo Creating $1_sr.dat + +$MATRIX << EOF | awk '$1 !~ /[A-Za-z]/ && NF>0 {print} ' >$1_sr.dat + + tmax=2; tstep=tmax/100; + T = [0:tstep:tmax]'; + [A,B,C,D,E] = $1_dm($1_numpar); + y = dm2sr(A,B,C,D,E,T); + + [Ny,Nu]=size(D); + NN = Ny*Nu; + + xy = [T y(:,1)]; + for i=2:NN + xy = [xy T y(:,i)]; + end; +xy + +EOF +