Home > m > timetools > statespacefunctions > ltpda_ss_ss2pz.m

ltpda_ss_ss2pz

PURPOSE ^

ltpda_ss_ss2pz converts a time continuousvstate space system into a

SYNOPSIS ^

function varargout = ltpda_ss_ss2pz(varargin)

DESCRIPTION ^

 ltpda_ss_ss2pz converts a time continuousvstate space system into a
 pzmodel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: ltpda_ss_ss2pz converts (an array of) time continuousvstate space system into a
 pzmodelt. The output field is an array of filter of 3 dimensions. First is
 the output (in the order specified), second the input, third the system.

 CALL: pzm = ltpda_ss_ss2pz(systs, Params)

 INPUTS: systs - state space subsystem array 
 Params - a plist containing the corresponding names of the inputs,
 row number, and output line number.

 OUTPUTS: pzm - a pzmodel object

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

 VERSION: $Id: ltpda_ss_ss2pz.html,v 1.2 2008/03/31 10:27:36 hewitson Exp $

 HISTORY:
 Creation 28-02-2008 A Grynagier

 To do :  more checks! Numerical and syntaxic.  
 Make clear what 'gain' and 'conn' argument to pzmodel are
 Also discuss the case when the ouput is in PFD form...
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = ltpda_ss_ss2pz(varargin)
0002 % ltpda_ss_ss2pz converts a time continuousvstate space system into a
0003 % pzmodel
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: ltpda_ss_ss2pz converts (an array of) time continuousvstate space system into a
0007 % pzmodelt. The output field is an array of filter of 3 dimensions. First is
0008 % the output (in the order specified), second the input, third the system.
0009 %
0010 % CALL: pzm = ltpda_ss_ss2pz(systs, Params)
0011 %
0012 % INPUTS: systs - state space subsystem array
0013 % Params - a plist containing the corresponding names of the inputs,
0014 % row number, and output line number.
0015 %
0016 % OUTPUTS: pzm - a pzmodel object
0017 %
0018 % ***** THERE ARE NO DEFAULT PARAMETERS *****
0019 %
0020 % VERSION: $Id: ltpda_ss_ss2pz.html,v 1.2 2008/03/31 10:27:36 hewitson Exp $
0021 %
0022 % HISTORY:
0023 % Creation 28-02-2008 A Grynagier
0024 %
0025 % To do :  more checks! Numerical and syntaxic.
0026 % Make clear what 'gain' and 'conn' argument to pzmodel are
0027 % Also discuss the case when the ouput is in PFD form...
0028 %
0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0030 
0031 %% standard calls for LTPDA function data
0032 
0033 ALGONAME = mfilename;
0034 VERSION = '$Id: ltpda_ss_ss2pz.html,v 1.2 2008/03/31 10:27:36 hewitson Exp $';
0035 CATEGORY = 'STATESPACE';
0036 display(['starting ' ALGONAME]);
0037 
0038 if not(isempty(varargin))
0039     if isequal( varargin{1}, 'Version')
0040         varargout = VERSION;
0041         return;
0042     elseif isequal(varargin{1}, 'Params')
0043         varargout = plist('INPUTS', 'U_1', 'INPUTCOLUMNS', 1 ,'OUTPUTROW',1);
0044         return;
0045     elseif isequal(varargin{1}, 'Category')
0046         varargout = CATEGORY;
0047         return;
0048     end
0049 end
0050 pzms = pzmodel();%found no other way to declare right size of iir array
0051 
0052 %% retriveing data
0053 systs = varargin{1};
0054 Params = varargin{2};
0055 INPUTS = find(Params, 'INPUTS');
0056 INPUTCOLUMNS = find(Params, 'INPUTCOLUMNS');
0057 if not(length(INPUTS)==length(INPUTCOLUMNS))
0058     msg ='error because differnent number of inputs and input columns specified';
0059     error(msg);
0060 end
0061 OUTPUTS = find(Params, 'OUTPUTROWS');
0062 for i_syst=1:length(systs) % for every system
0063     syst = systs(i_syst);
0064     AMAT = find(syst,'AMAT');
0065     CMAT = find(syst,'CMAT');
0066     BMATS = find(syst,'BMATS');
0067     DMATS = find(syst,'DMATS');
0068     Ninputs = find(syst,'NBINPUTS');
0069     NAME = find(syst,'NAME');
0070     INPUTSIZES = find(syst,'INPUTSIZES');
0071     INPUTNAMES = find(syst,'INPUTNAMES');
0072     STEPSIZE = find(syst,'TIMESTEP');
0073     for i_inputs=1:length(INPUTS) % for every input
0074         j_inputs =0;
0075         for i=1:Ninputs %finding corresponding indice in the system
0076             if isequal(INPUTNAMES{i}, INPUTS{i_inputs})
0077                 j_inputs = i;
0078             end
0079         end
0080         if j_inputs == 0
0081             error(['error : Input name ', INPUTS{i_inputs} ,' not found in system ', NAME])
0082             
0083         elseif INPUTCOLUMNS(i_inputs) > INPUTSIZES(j_inputs)
0084             error(['error: Input name ', INPUTS{i_inputs} ,' in system ', NAME, ' was given with a row indice ', num2str(INPUTCOLUMNS(i_inputs)), ' bigger than possible ', num2str(INPUTSIZES(j_inputs)) ])
0085         end
0086         %% part where model is extracted
0087         for i_outputs=1:length(OUTPUTS)
0088             if STEPSIZE == 0
0089                 if size(BMATS{j_inputs},2)==0 ||size(CMAT{1},1)==0 %should not be called anymore
0090                     pzms(i_outputs,i_inputs,i_syst) = {};
0091                 elseif size(AMAT{1},1)==0
0092                     D = DMATS{j_inputs};
0093                     Gain = D(OUTPUTS(i_outputs),INPUTCOLUMNS(i_inputs));
0094                     p = pole();
0095                     z = pole();
0096                     pzms(i_outputs,i_inputs,i_syst) = pzmodel(plist('zeros', p, 'poles', z, 'gain', Gain, 'name', [NAME,'_',INPUTNAMES{i}], 'conn', 'WHAT?'));
0097                 else
0098                     C = CMAT{1};
0099                     B = BMATS{j_inputs};
0100                     D = DMATS{j_inputs};
0101                     d = D(OUTPUTS(i_outputs),INPUTCOLUMNS(i_inputs));
0102                     [a,b] = ss2tf(AMAT{1}, B(:,INPUTCOLUMNS(i_inputs)), C(OUTPUTS(i_outputs),:), D(OUTPUTS(i_outputs),INPUTCOLUMNS(i_inputs)));
0103                     p = factorize(a,'poles');
0104                     z = factorize(b,'zeros');
0105                     Gain = 1;
0106                     pzms(i_outputs,i_inputs,i_syst) = pzmodel(plist('zeros', p, 'poles', z, 'gain', Gain, 'name', [NAME,'_',INPUTNAMES{i}], 'conn', 'WHAT?'));
0107                 end
0108             else
0109                 display('Error because timestep must be zero to make a pole zero model');
0110             end
0111         end
0112     end
0113 end
0114 varargout = {pzms};
0115 end
0116

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003