Home > m > timetools > statespacefunctions > ltpda_ss_pz2ss.m

ltpda_ss_pz2ss

PURPOSE ^

% conversion from a pole zero model

SYNOPSIS ^

function varargout = ltpda_ss_pz2ss(varargin)

DESCRIPTION ^

% conversion from a pole zero model

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% conversion from a pole zero model
0002 
0003 function varargout = ltpda_ss_pz2ss(varargin)
0004 % ltpda_pz2ss converts a pole-zero model into a subsystem.
0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0006 %
0007 % DESCRIPTION: ltpda_pz2ss converts a pole-zero model into a subsystem.
0008 %
0009 % CALL: subsys = ltpda_pz2ss(pzm)
0010 %
0011 % INPUTS: 3 possibilites
0012 % pzm - a pole zero model object
0013 %
0014 % OUTPUTS: subsys - subsystem dscribed by a plist
0015 %
0016 % subsystem plist format (More updated infos might be available in the
0017 % ltpda_ss_check function):
0018 % plist('TYPE', TYPE ,'NAME', NAME ,'TIMESTEP', TIMESTEP ,...
0019 %     'PARAMNAMES', PARAMNAMES ,'PARAMVALUES', PARAMVALUES ,'PARAMSIGMAS', PARAMSIGMAS ,...
0020 %     'NBINPUTS', NBINPUTS ,'INPUTNAMES', INPUTNAMES ,'INPUTSIZES', INPUTSIZES ,'INPUTISUSED', INPUTISUSED ,...
0021 %     'AMAT', AMAT ,'BMATS', BMATS ,'CMAT', CMAT ,'DMATS', DMATS );% PARAMETERS:
0022 % 'TYPE' should be 'SUBSYSTEM'
0023 % 'NAME' is a string
0024 % 'TIMESTEP' is a real positive integer, set to zero in continuous case
0025 % 'PARAMNAMES' cell array of strings describing parameter variables
0026 % 'PARAMVALUES' array of doubles (means expected of parameters)
0027 % 'PARAMSIGMAS' array of doubles (variance expected of parameters)
0028 % 'NBINPUTS' integer number of inputs
0029 % 'INPUTNAMES' cell array of strings (name of the inputs)
0030 % 'INPUTSIZES'array of integers (nb of dimensions of the inputs),
0031 % 'INPUTISUSED' double array (binary to indicate which inputs are used)
0032 % 'AMAT' cell array (contains A matrix)
0033 % 'BMATS' cell array (contains B matrices)
0034 % 'CMAT' cell array (contains C matrix)
0035 % 'DMATS' cell array (contains D matrices)
0036 % ***** THERE ARE NO DEFAULT PARAMETERS *****
0037 %
0038 % VERSION: $Id: ltpda_ss_pz2ss.m,v 1.5 2008/03/11 16:52:56 adrien Exp $
0039 %
0040 % TO DO : check acceptability of deconv function output
0041 % lots of testing including numerical checks.
0042 % Discuss the possiblity of jordan block form and PFD form for the output
0043 % pz model
0044 %
0045 % HISTORY: 26-02-2008 A Grynagier
0046 % 01-02-2008 A Grynagier
0047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0048 
0049 ALGONAME = mfilename;
0050 VERSION = '$Id: ltpda_ss_pz2ss.m,v 1.5 2008/03/11 16:52:56 adrien Exp $';
0051 CATEGORY = 'STATESPACE';
0052 display(['starting ' ALGONAME]);
0053 
0054 if not(isempty(varargin))
0055     if isequal( varargin{1}, 'Version')
0056         varargout = VERSION;
0057         return;
0058     elseif isequal(varargin{1}, 'Params')
0059         varargout = plist();
0060         return;
0061     elseif isequal(varargin{1}, 'Category')
0062         varargout = CATEGORY;
0063         return;
0064     end
0065 end
0066 % for next part check must be made there is no pole zero cancelation
0067 pzms = varargin{1};
0068 system = plist;
0069 for i_pzm=1:length(pzms)
0070     pzm = pzms(i_pzm);
0071     %% building numerator
0072     poles = pzm.poles;
0073     a = 1;
0074     for i = 1:length(poles)
0075         p=poles(i);
0076         w0 = 2*pi*get(p, 'f');
0077         if isequal(p.name,'real pole')
0078             a_p = [1 -1/(w0)];
0079         elseif isequal(p.name,'complex pole')
0080             q  = get(poles(i), 'q');
0081             a_p = [1 w0/q w0^2];
0082         else
0083             error('type of pole not expected')
0084         end
0085         a = conv(a,a_p); %multplication of polynomials to get denominator
0086     end
0087     %% building denominator
0088     Zeros = pzm.zeros;
0089     b = 1;
0090     for i = 1:length(Zeros)
0091         z = Zeros(i);
0092         w0 = 2*pi*get(z, 'f');
0093         if isequal(z.name,'real zero')
0094             b_z = [1 -w0];
0095         elseif isequal(z.name,'complex zero')
0096             q  = get(Zeros(i), 'q');
0097             b_z = [1 w0/q w0^2];
0098         else
0099             error('type of zero not expected')
0100         end
0101         b = conv(b,b_z); %multplication of polynomials to get numerator
0102     end
0103 
0104     %% building matrices
0105     nss = size(b,2)-1;
0106     [d,a2] = deconv(a,b);
0107     A = [zeros(nss-1, 1) eye(nss-1); fliplr(b(1,2:nss+1))];
0108     B = [zeros(nss-1, 1); 1];
0109     C = fliplr(a2(2:nss+1));
0110     D = d;
0111 
0112     %% parsing subsystem
0113     system(i_pzm) = plist('TYPE', 'SUMBSYSTEM' ,'NAME', pzm.name ,'TIMESTEP', 0 , ...
0114         'XISOUTPUT', 0,'YISOUTPUT',1,'XINI', zeros(nss,1) , ...
0115         'PARAMNAMES', {},'PARAMVALUES', [],'PARAMSIGMAS', [],...
0116         'NBINPUTS', 1 ,'INPUTNAMES', {'U_1'} ,'INPUTSIZES', 1 , 'INPUTISUSED', 1 ,...
0117         'AMAT', {A} ,'BMATS', {B} ,'CMAT', {C} ,'DMATS', {D} );
0118 end
0119 varargout = {system};
0120 end

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