Home > classes > @ssm > double.m

double

PURPOSE ^

Convert a statespace model object to double arrays for given i/o

SYNOPSIS ^

function varargout = double(varargin)

DESCRIPTION ^

 Convert a statespace model object to double arrays for given i/o
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: double converts a statespace model object to double arrays.

 CALL:        [A B C D Ts inputvarnames2 ssvarnames2 outputvarnames2] = double(ssm, options);

 INPUTS :   
             ssm     - a ssm object
             options - an options plist
 
 OPTIONS :
 plist with parameters 'inputs', 'states' and 'outputs' to indicate which
 inputs, states and outputs variables are taken in account. This requires
 proper variable naming. If a variable called appears more that once it
 will be used once only.
 The field may be :
              - a cellstr containing the resp. input/state/output *variable* names
              - a logical indexing the resp. input/state/output *variables*
              names. Index is stored in a cell array, each cell
              correponding to one input/state/output block.
              - a double indexing the resp. input/state/output *variables*
              names. Index is stored in a cell array, each cell
              correponding to one input/state/output block.
              - 'ALL', this string indicates all i/o variables will be
              given

 
 OUTPUTS :    A                - the As matrices in one double array
              B                - the Bs matrices in one double array
              C                - the Cs matrices in one double array
              D                - the Ds matrices in one double array
              Ts               - the sampling time of the system. 0 is
                                 continuous
              inputvarnames2   - the variable names corresponding to the
                                 columns of B and D
              ssvarnames2      - the variable names corresponding to the
                                 rows of A and B, cols. of A and C
              outputvarnames2  - the variable names corresponding to the
                                 rows of C and D
 
 
 VERSION:     $Id: double.m,v 1.6 2008/06/08 18:44:07 adrien Exp $

 M-FILE INFO: Get information about this methods by calling
              >> ssm.getInfo('double')

              Get information about a specified set-plist by calling:
              >> ssm.getInfo('double', 'Default')

 HISTORY:    07-08-2008 Grynagier
             16-04-08 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % Convert a statespace model object to double arrays for given i/o
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: double converts a statespace model object to double arrays.
0005 %
0006 % CALL:        [A B C D Ts inputvarnames2 ssvarnames2 outputvarnames2] = double(ssm, options);
0007 %
0008 % INPUTS :
0009 %             ssm     - a ssm object
0010 %             options - an options plist
0011 %
0012 % OPTIONS :
0013 % plist with parameters 'inputs', 'states' and 'outputs' to indicate which
0014 % inputs, states and outputs variables are taken in account. This requires
0015 % proper variable naming. If a variable called appears more that once it
0016 % will be used once only.
0017 % The field may be :
0018 %              - a cellstr containing the resp. input/state/output *variable* names
0019 %              - a logical indexing the resp. input/state/output *variables*
0020 %              names. Index is stored in a cell array, each cell
0021 %              correponding to one input/state/output block.
0022 %              - a double indexing the resp. input/state/output *variables*
0023 %              names. Index is stored in a cell array, each cell
0024 %              correponding to one input/state/output block.
0025 %              - 'ALL', this string indicates all i/o variables will be
0026 %              given
0027 %
0028 %
0029 % OUTPUTS :    A                - the As matrices in one double array
0030 %              B                - the Bs matrices in one double array
0031 %              C                - the Cs matrices in one double array
0032 %              D                - the Ds matrices in one double array
0033 %              Ts               - the sampling time of the system. 0 is
0034 %                                 continuous
0035 %              inputvarnames2   - the variable names corresponding to the
0036 %                                 columns of B and D
0037 %              ssvarnames2      - the variable names corresponding to the
0038 %                                 rows of A and B, cols. of A and C
0039 %              outputvarnames2  - the variable names corresponding to the
0040 %                                 rows of C and D
0041 %
0042 %
0043 % VERSION:     $Id: double.m,v 1.6 2008/06/08 18:44:07 adrien Exp $
0044 %
0045 % M-FILE INFO: Get information about this methods by calling
0046 %              >> ssm.getInfo('double')
0047 %
0048 %              Get information about a specified set-plist by calling:
0049 %              >> ssm.getInfo('double', 'Default')
0050 %
0051 % HISTORY:    07-08-2008 Grynagier
0052 %             16-04-08 M Hewitson
0053 %             Creation
0054 %
0055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0056 
0057 function varargout = double(varargin)
0058 
0059   %% starting initial checks
0060   utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
0061   
0062   % Check if this is a call for parameters
0063   if utils.helper.isinfocall(varargin{:})
0064     varargout{1} = getInfo(varargin{3});
0065     return
0066   end
0067 
0068   % checking number of inputs work data
0069   if ~nargin==2, error('wrong number of inputs!'), end
0070 
0071   if ~isequal(class(varargin{1}),'ssm'), error(['argument is not a ssm but a ', class(varargin{1})]),end
0072   if ~isequal(class(varargin{2}),'plist'), error(['argument is not a plist but a ', class(varargin{2})]),end
0073 
0074   sys = varargin{1};
0075   options = combine(varargin{2}, getDefaultPlist('Default'));
0076   %% begin function body
0077   %making model simplifications
0078   sys = reduce_model(sys, options);
0079   
0080   %  Convert to double arrays
0081 
0082   M =          ssm.cell_fusion(sys.mmats, sys.sssizes,     sys.sssizes);
0083   A = (M^-1) * ssm.cell_fusion(sys.amats, sys.sssizes,     sys.sssizes);
0084   B = (M^-1) * ssm.cell_fusion(sys.bmats, sys.sssizes,     sys.inputsizes);
0085   C =          ssm.cell_fusion(sys.cmats, sys.outputsizes, sys.sssizes);
0086   D =          ssm.cell_fusion(sys.dmats, sys.outputsizes, sys.inputsizes);
0087   Ts = sys.timestep;
0088   
0089   inputvarnames3 = cell(1,sum(sys.inputsizes));
0090   k=1;
0091   for i=1:sys.Ninputs
0092     for j=1:sys.inputsizes(i)
0093       inputvarnames3{k} = sys.inputvarnames{i}{j};
0094       k = k+1;
0095     end
0096   end
0097   ssvarnames3 = cell(1,sum(sys.sssizes));
0098   k=1;
0099   for i=1:sys.Nss
0100     for j=1:sys.sssizes(i)
0101       ssvarnames3{k} = sys.ssvarnames{i}{j};
0102       k = k+1;
0103     end
0104   end
0105   outputvarnames3 = cell(1,sum(sys.outputsizes));
0106   k=1;
0107   for i=1:sys.Noutputs
0108     for j=1:sys.outputsizes(i)
0109       outputvarnames3{k} = sys.outputvarnames{i}{j};
0110       k = k+1;
0111     end
0112   end
0113 
0114   
0115 %% parsing output
0116   varargout = {A B C D Ts inputvarnames3 ssvarnames3 outputvarnames3};
0117 
0118 end
0119 
0120 
0121 function ii = getInfo(varargin)
0122   if nargin == 1 && strcmpi(varargin{1}, 'None')
0123     sets = {};
0124     pls   = [];
0125   elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1})
0126     sets{1} = varargin{1};
0127     pls = getDefaultPlist(sets{1});
0128   else
0129     sets = {'Default'};
0130     pls = [];
0131     for kk=1:numel(sets)
0132       pls = [pls getDefaultPlist(sets{kk})];
0133     end
0134   end
0135   % Build info object
0136   ii = minfo(mfilename, 'ssm', '', 'STATESPACE', '$Id: resp.m,v 1.17 2008/07/22 10:22:38 ingo Exp $', sets, pls);
0137 end
0138 
0139 function plo = getDefaultPlist(set)
0140   switch set
0141     case 'Default'
0142       plo = ssm.getInfo('reduce_model', 'Default').plists;
0143     otherwise
0144       error('### Unknown parameter set [%s].', set);
0145   end
0146 end

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003