


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.17 2008/08/21 19:51:44 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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.17 2008/08/21 19:51:44 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 varargout{1} = sys; 0069 0070 end 0071 0072 0073 function ii = getInfo(varargin) 0074 if nargin == 1 && strcmpi(varargin{1}, 'None') 0075 sets = {}; 0076 pls = []; 0077 elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1}) 0078 sets{1} = varargin{1}; 0079 pls = getDefaultPlist(sets{1}); 0080 else 0081 sets = {'Default'}; 0082 pls = []; 0083 for kk=1:numel(sets) 0084 pls = [pls getDefaultPlist(sets{kk})]; 0085 end 0086 end 0087 % Build info object 0088 ii = minfo(mfilename, 'ssm', '', 'STATESPACE', '$Id: ssm2ss.m,v 1.17 2008/08/21 19:51:44 adrien Exp $', sets, pls); 0089 end 0090 0091 function plo = getDefaultPlist(set) 0092 switch set 0093 case 'Default' 0094 plo = ssm.getInfo('reduce_model', 'Default').plists; 0095 otherwise 0096 error('### Unknown parameter set [%s].', set); 0097 end 0098 end 0099