Home > m > timetools > statespacefunctions > utp_ltpda_ss_simulate.m

utp_ltpda_ss_simulate

PURPOSE ^

tests ltpda_simulate_discrete which simulates a discrete state space system

SYNOPSIS ^

function varargout = utp_ltpda_ss_simulate(varargin)

DESCRIPTION ^

tests ltpda_simulate_discrete which simulates a discrete state space system
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: tests ltpda_simulate_discrete whichsimulates a discrete
 state space system

 CALL: utp_ltpda_simulate_discrete

 INPUTS: 
 
 OUTPUTS: result - 1/0

 ***** THERE ARE NO DEFAULT PARAMETERS *****

 &&VERSION: $Id: utp_ltpda_ss_simulate.m,v 1.1 2008/03/11 16:52:56 adrien Exp $

 HISTORY: 17-02-2008 A Grynagier

 TO DO: Numerical and syntaxic tests
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = utp_ltpda_ss_simulate(varargin)
0002 %tests ltpda_simulate_discrete which simulates a discrete state space system
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % DESCRIPTION: tests ltpda_simulate_discrete whichsimulates a discrete
0006 % state space system
0007 %
0008 % CALL: utp_ltpda_simulate_discrete
0009 %
0010 % INPUTS:
0011 %
0012 % OUTPUTS: result - 1/0
0013 %
0014 % ***** THERE ARE NO DEFAULT PARAMETERS *****
0015 %
0016 % &&VERSION: $Id: utp_ltpda_ss_simulate.m,v 1.1 2008/03/11 16:52:56 adrien Exp $
0017 %
0018 % HISTORY: 17-02-2008 A Grynagier
0019 %
0020 % TO DO: Numerical and syntaxic tests
0021 %
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 ALGONAME = mfilename;
0024 VERSION = '$Id: utp_ltpda_ss_simulate.m,v 1.1 2008/03/11 16:52:56 adrien Exp $';
0025 CATEGORY = 'STATESPACE';
0026 display(['starting ' ALGONAME]);
0027 
0028 if not(isempty(varargin))
0029     if isequal( varargin{1}, 'Version')
0030         varargout = VERSION;
0031         return;
0032     elseif isequal(varargin{1}, 'Params')
0033         varargout = plist();
0034         return;
0035     elseif isequal(varargin{1}, 'Category')
0036         varargout = CATEGORY;
0037         return;
0038     end
0039 end
0040 result = 1;
0041  
0042 try
0043     %% create subsystem
0044     %% test numerique
0045     A=expm([0 1; -2 -1]);
0046     B1=[0;1];
0047     C=[2 -1];
0048     D1=1;
0049     B2=[0;0];
0050     D2=1;
0051     sigma = 0.5;
0052     mean = 10;
0053     syst = plist('TYPE', 'SUBSYSTEM' ,'NAME', 'SS1' ,'TIMESTEP', 1 , ...
0054         'XISOUTPUT',0,'YISOUTPUT',1,'XINI', [0 0]' , ...
0055         'PARAMNAMES', {} ,'PARAMVALUES', [] ,'PARAMSIGMAS', [] ,...
0056         'NBINPUTS', 2 ,'INPUTNAMES', {'U' 'N'} ,'INPUTSIZES', [1 1] , 'INPUTISUSED', [1 1] ,...
0057         'AMAT', {A} ,'BMATS', {B1 B2} ,'CMAT', {C} ,'DMATS', {D1 D2} );
0058     syst = [syst, syst];
0059     ao1 = ao(sin((1:100)'/3));
0060     ao_in_list = [plist('U',ao1, 'N', plist('SIGMA', sigma, 'MEAN',mean)), plist('U',ao1, 'N', plist('SIGMA', sigma*8, 'MEAN',mean))];
0061     ao_out = ltpda_ss_simulate(ao_in_list, syst);
0062 
0063     data_plist = plist('Qs',{0},'Rs',{sigma^2+mean^2},'Noise_Names',{'N'} );
0064 
0065     ao_in_list2 = plist('U',ao1);
0066     ao_id = ltpda_ss_kalman_filter(ao_out(1), ao_in_list2(1), data_plist(1), syst(1));
0067 
0068     figure(1)
0069     plot(ao_out(1))
0070     figure(2)
0071     plot(ao_id(1))
0072 catch
0073     result = 0;
0074 end
0075 varargout = {result};
0076 end

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003