Index: mttroot/mtt/bin/trans/m/sm2ir.m ================================================================== --- mttroot/mtt/bin/trans/m/sm2ir.m +++ mttroot/mtt/bin/trans/m/sm2ir.m @@ -1,11 +1,25 @@ function [Y,X] = sm2ir(A,B,C,D,T,u0,x0); +% sm2ir - Constrained-state matrix to impulse response. +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function sm2ir % [Y,X] = sm2ir(A,B,C,D,T,u0,x0); -% Constrained-state matrix to impulse response. % A,B,C,D,E - (constrained) state matrices % T vector of time points -% u0 input gain vector: u = u0*unit step. +% u0 input gain vector: u = u0*unit impulse. + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [Ny,Nu] = size(D); [Ny,Nx] = size(C); @@ -32,16 +46,21 @@ one = eye(Nx); Y = zeros(N,Ny); X = zeros(N,Nx); + +dt = T(2)-T(1);% Assumes fixed interval +expAdt = expm(A*dt); % Compute matrix exponential +expAt = one; i = 0; +x = (B*u0+x0); for t = T' i=i+1; if Nx>0 - expAt = expm(A*t); - x = expAt*(B*u0+x0); + % expAt = expm(A*t); + x = expAdt*x; X(i,:) = x'; if Ny>0 y = C*x; Y(i,:) = y'; end;