Home > classes > @ssm > ssm2ss.m

ssm2ss

PURPOSE ^

SSM2SS converts a statespace model object to a MATLAB statespace object.

SYNOPSIS ^

function varargout = ssm2ss(varargin)

DESCRIPTION ^

 SSM2SS converts a statespace model object to a MATLAB statespace object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: SSM2SS converts a statespace model object to a MATLAB statespace object.

 CALL:        Convert a statespace model object to a MATLAB statespace object.
              >> ss = ssm2ss(ssm, options);

 ssm -     ssm object
 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

 VERSION:     $Id: ssm2ss.m,v 1.18 2008/08/26 20:55:27 adrien Exp $

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

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

 HISTORY: 16-04-08 M Hewitson
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % SSM2SS converts a statespace model object to a MATLAB statespace object.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: SSM2SS converts a statespace model object to a MATLAB statespace object.
0005 %
0006 % CALL:        Convert a statespace model object to a MATLAB statespace object.
0007 %              >> ss = ssm2ss(ssm, options);
0008 %
0009 % ssm -     ssm object
0010 % plist with parameters 'inputs', 'states' and 'outputs' to indicate which
0011 % inputs, states and outputs variables are taken in account. This requires
0012 % proper variable naming. If a variable called appears more that once it
0013 % will be used once only.
0014 % The field may be :
0015 %              - a cellstr containing the resp. input/state/output *variable* names
0016 %              - a logical indexing the resp. input/state/output *variables*
0017 %              names. Index is stored in a cell array, each cell
0018 %              correponding to one input/state/output block.
0019 %              - a double 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 %              - 'ALL', this string indicates all i/o variables will be
0023 %              given
0024 %
0025 % VERSION:     $Id: ssm2ss.m,v 1.18 2008/08/26 20:55:27 adrien Exp $
0026 %
0027 % M-FILE INFO: Get information about this methods by calling
0028 %              >> ssm.getInfo('ssm2ss')
0029 %
0030 %              Get information about a specified set-plist by calling:
0031 %              >> ssm.getInfo('ssm2ss', 'Default')
0032 %
0033 % HISTORY: 16-04-08 M Hewitson
0034 %             Creation
0035 %
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 
0038 function varargout = ssm2ss(varargin)
0039 
0040 %% starting initial checks
0041 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
0042 
0043 % Check if this is a call for parameters
0044 if utils.helper.isinfocall(varargin{:})
0045   varargout{1} = getInfo(varargin{3});
0046   return
0047 end
0048 
0049 % checking number of inputs work data
0050 if ~nargin==2, error('wrong number of inputs!'), end
0051 
0052 if ~isequal(class(varargin{1}),'ssm'), error(['argument is not a ssm but a ', class(varargin{1})]),end
0053 if ~isequal(class(varargin{2}),'plist'), error(['argument is not a plist but a ', class(varargin{2})]),end
0054 
0055 obj = varargin{1};
0056 options = combine(varargin{2}, getDefaultPlist('Default'));
0057 
0058 %% begin function body
0059 if ~obj.isnumerical
0060   error('system should be numeric')
0061 end
0062 
0063 [A,B,C,D,Ts,inputvarnames,ssvarnames, outputvarnames] = double(obj, options);
0064 sys = ss(A,B,C,D,Ts);
0065 sys.StateName = ssvarnames;
0066 sys.InputName = inputvarnames;
0067 sys.OutputName = outputvarnames;
0068 sys.Notes = obj.description;
0069 sys.Name = obj.name;
0070 varargout{1} = sys;
0071 
0072 end
0073 
0074 
0075 function ii = getInfo(varargin)
0076   if nargin == 1 && strcmpi(varargin{1}, 'None')
0077     sets = {};
0078     pls   = [];
0079   elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1})
0080     sets{1} = varargin{1};
0081     pls = getDefaultPlist(sets{1});
0082   else
0083     sets = {'Default'};
0084     pls = [];
0085     for kk=1:numel(sets)
0086       pls = [pls getDefaultPlist(sets{kk})];
0087     end
0088   end
0089   % Build info object
0090   ii = minfo(mfilename, 'ssm', '', 'STATESPACE', '$Id: ssm2ss.m,v 1.18 2008/08/26 20:55:27 adrien Exp $', sets, pls);
0091 end
0092 
0093 function plo = getDefaultPlist(set)
0094   switch set
0095     case 'Default'
0096       plo = ssm.getInfo('reduce_model', 'Default').plists;
0097     otherwise
0098       error('### Unknown parameter set [%s].', set);
0099   end
0100 end
0101

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