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.3 2008/02/25 12:43:44 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: 01-02-2008 A Grynagier
0046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0047 
0048 ALGONAME = mfilename;
0049 VERSION = '$Id: ltpda_ss_pz2ss.m,v 1.3 2008/02/25 12:43:44 adrien Exp $';
0050 CATEGORY = 'STATESPACE';
0051 display(['starting ' ALGONAME]);
0052 
0053 if isequal( varargin{1}, 'Version')
0054     varargout = VERSION;
0055     return;
0056 elseif isequal(varargin{1}, 'Params')
0057     varargout = plist();
0058     return;
0059 elseif isequal(varargin{1}, 'Category')
0060     varargout = CATEGORY;
0061     return;
0062 end
0063 
0064 % for next part check must be made there is no pole zero cancelation
0065 pzm = varargin{1};
0066 %% building numerator
0067 poles = pzm.poles;
0068 a = 1;
0069 for i = 1:length(poles)
0070     p=poles(i);
0071     w0 = 2*pi*get(p, 'f');
0072     if isequal(p.name,'real pole')
0073         a_p = [1 -1/(w0)];
0074     elseif isequal(p.name,'complex pole')
0075         q  = get(poles(i), 'q');
0076         a_p = [1 w0/q w0^2];
0077     else
0078         error('type of pole not expected')
0079     end
0080     a = conv(a,a_p); %multplication of polynomials to get denominator
0081 end
0082 %% building denominator
0083 Zeros = pzm.zeros;
0084 b = 1;
0085 for i = 1:length(Zeros)
0086     z = Zeros(i);
0087     w0 = 2*pi*get(z, 'f');
0088     if isequal(z.name,'real zero')
0089         b_z = [1 -w0];
0090     elseif isequal(z.name,'complex zero')
0091         q  = get(Zeros(i), 'q');
0092         b_z = [1 w0/q w0^2];
0093     else
0094         error('type of zero not expected')
0095     end
0096     b = conv(b,b_z); %multplication of polynomials to get numerator
0097 end    
0098 
0099 %% building matrices
0100 nss = size(b,2)-1;
0101 [d,a2] = deconv(a,b);
0102 A = [zeros(nss-1, 1) eye(nss-1); fliplr(b(1,2:nss+1))]; 
0103 B = [zeros(nss-1, 1); 1];
0104 C = fliplr(a2(2:nss+1));
0105 D = d;
0106 
0107 %% parsing subsystem
0108 varargout = plist('TYPE', 'SUMBSYSTEM' ,'NAME', pzm.name ,'TIMESTEP', 0 , ...
0109     'XISOUTPUT', 0,'YISOUTPUT',1,'XINI', zeros(nss,1) , ...
0110     'PARAMNAMES', {},'PARAMVALUES', [],'PARAMSIGMAS', [],...
0111     'NBINPUTS', 1 ,'INPUTNAMES', {'U_1'} ,'INPUTSIZES', 1 , 'INPUTISUSED', 1 ,...
0112     'AMAT', {A} ,'BMATS', {B} ,'CMAT', {C} ,'DMATS', {D} );
0113 end

Generated on Tue 26-Feb-2008 10:52:52 by m2html © 2003