Home > m > timetools > statespacefunctions > ltpda_ss_ss2iir.m

ltpda_ss_ss2iir

PURPOSE ^

makeSubsystem is the generic function to decalre or load a subsystem.

SYNOPSIS ^

function varargout = ltpda_ss_ss2iir(varargin)

DESCRIPTION ^

 makeSubsystem is the generic function to decalre or load a subsystem.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: ltpda_ss_tofiir

 CALL: iir = ltpda_ss_tofiir(varargin)

 INPUTS: subsys - subsystem dscribed by a plist

 OUTPUTS: iir - a miiir object

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

 VERSION: $Id: ltpda_ss_ss2iir.m,v 1.2 2008/02/25 12:43:44 adrien Exp $

 HISTORY: 10-02-2008
 22-01-2008 A Grynagier
 Creation 02-01-2008 A Grynagier

 To do :  more checks! Numerical and syntaxic.  UNDERSTAND WHY CURRENT
 MIIR CALL DOES NOT WORK
 Also discuss the case when the ouput is in PFD form...
 Replace output cell array by output array
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = ltpda_ss_ss2iir(varargin)
0002 % makeSubsystem is the generic function to decalre or load a subsystem.
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % DESCRIPTION: ltpda_ss_tofiir
0006 %
0007 % CALL: iir = ltpda_ss_tofiir(varargin)
0008 %
0009 % INPUTS: subsys - subsystem dscribed by a plist
0010 %
0011 % OUTPUTS: iir - a miiir object
0012 %
0013 % ***** THERE ARE NO DEFAULT PARAMETERS *****
0014 %
0015 % VERSION: $Id: ltpda_ss_ss2iir.m,v 1.2 2008/02/25 12:43:44 adrien Exp $
0016 %
0017 % HISTORY: 10-02-2008
0018 % 22-01-2008 A Grynagier
0019 % Creation 02-01-2008 A Grynagier
0020 %
0021 % To do :  more checks! Numerical and syntaxic.  UNDERSTAND WHY CURRENT
0022 % MIIR CALL DOES NOT WORK
0023 % Also discuss the case when the ouput is in PFD form...
0024 % Replace output cell array by output array
0025 %
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 %% standard calls for LTPDA function data
0029 
0030 ALGONAME = mfilename;
0031 VERSION = '$Id: ltpda_ss_ss2iir.m,v 1.2 2008/02/25 12:43:44 adrien Exp $';
0032 CATEGORY = 'STATESPACE';
0033 display(['starting ' ALGONAME]);
0034 
0035 if isequal( varargin{1}, 'Version')
0036     varargout = VERSION;
0037     return;
0038 elseif isequal(varargin{1}, 'Params')
0039     varargout = plist();
0040     return;
0041 elseif isequal(varargin{1}, 'Category')
0042     varargout = CATEGORY;
0043     return;
0044 end
0045 
0046 %% proceeding data
0047 syst = varargin{1};
0048 
0049 AMAT = find(syst,'AMAT');
0050 CMAT = find(syst,'CMAT');
0051 BMATS = find(syst,'BMATS');
0052 DMATS = find(syst,'DMATS');
0053 Ninputs = find(syst,'NBINPUTS');
0054 NAME = find(syst,'NAME');
0055 % INPUTSIZES = find(syst,'IMPUTSIZES');
0056 INPUTNAMES = find(syst,'INPUTNAMES');
0057 STEPSIZE = find(syst,'TIMESTEP');    
0058 
0059 syms s
0060 %found no other way to declare right size of iir array
0061 iirs{1,1,1} = miir();
0062 if STEPSIZE == 0
0063     %to do instead : discretize system to 0.1s
0064     display('Error because timestep must be nonzero to make a time discrete filter');
0065     STEPSIZE = 1;
0066 end
0067 for i=1:Ninputs
0068     if size(AMAT{1},1)==0
0069         D = DMATS{i};
0070         C = CMAT{1};
0071         for j=1:size(C,1)
0072             for k=1:size(D,2)
0073                 a = D(j,k);
0074                 b = 1;
0075                 iirs{i,j,k} = miir(plist('a', a, 'b', b, 'gain', 1, 'ntaps', 1, 'name', [NAME,'_',INPUTNAMES{i}], 'fs', 1/STEPSIZE));
0076             end
0077         end
0078     elseif size(BMATS{i},2)==0 ||size(CMAT{1},1)==0
0079         iirs{i,1,1} = {};
0080     else
0081         C = CMAT{1};
0082         B = BMATS{i};
0083         D = DMATS{i};
0084         for j=1:size(C,1)
0085             for k=1:size(B,2)
0086                 [a,b] = ss2tf(AMAT{1}, B(:,k), C(j,:), D(j,k));
0087                 Gain=1;
0088                 m = miir();
0089                 m.a = a;
0090                 m.b = b;
0091                 m.fs = 1/STEPSIZE;
0092                 m.name = [NAME,'_',INPUTNAMES{i}];
0093                 m.gain = Gain;
0094                 iirs{i,j,k} = m;
0095 %                 iirs{i,j,k} = miir(plist('a', a, 'b', b, 'gain', Gain, 'ntaps', 1, 'name', [NAME,'_',INPUTNAMES{i}], 'fs', 1/STEPSIZE));
0096             end
0097         end
0098     end
0099 end
0100 varargout = iirs;
0101 end
0102

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