comparison m-toolbox/classes/@ssm/ssm2ss.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SSM2SS converts a statespace model object to a MATLAB statespace object.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SSM2SS converts a statespace model object to a MATLAB statespace object.
5 %
6 % CALL: Convert a statespace model object to a MATLAB statespace object.
7 % >> ss = ssm2ss(ssm, pl);
8 %
9 % ssm - ssm object
10 % plist with parameters 'inputs', 'states' and 'outputs' to indicate which
11 % inputs, states and outputs variables are taken in account. This requires
12 % proper variable naming. If a variable called appears more that once it
13 % will be used once only.
14 %
15 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'ssm2ss')">Parameters Description</a>
16 %
17 % VERSION: $Id: ssm2ss.m,v 1.33 2011/04/08 08:56:23 hewitson Exp $
18 %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21 function varargout = ssm2ss(varargin)
22
23 %% starting initial checks
24 % Check if this is a call for parameters
25 if utils.helper.isinfocall(varargin{:})
26 varargout{1} = getInfo(varargin{3});
27 return
28 end
29
30 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
31
32 in_names = cell(size(varargin));
33 for ii = 1:nargin,in_names{ii} = inputname(ii);end
34
35 [obj, ssm_invars, rest] = utils.helper.collect_objects(varargin(:), 'ssm', in_names);
36 [pl, invars2, rest] = utils.helper.collect_objects(rest(:), 'plist');
37 if ~isempty(rest)
38 pl = combine(pl, plist(rest{:}));
39 end
40 pl = combine(pl, getDefaultPlist());
41
42 %% begin function body
43 if ~obj.isnumerical
44 error('system should be numeric')
45 end
46 if nargout == numel(obj)
47 for ii = 1:numel(obj)
48 [A,B,C,D,Ts,inputvarnames,ssvarnames, outputvarnames] = double(obj(ii), pl);
49 sys = ss(A,B,C,D,Ts);
50 sys.StateName = ssvarnames;
51 sys.InputName = inputvarnames;
52 sys.OutputName = outputvarnames;
53 sys.Notes = obj.description;
54 sys.Name = obj.name;
55 varargout{ii} = sys;
56 end
57 else
58 [A,B,C,D,Ts,inputvarnames,ssvarnames, outputvarnames] = double(obj, pl);
59 sys = ss(A,B,C,D,Ts);
60 sys.StateName = ssvarnames;
61 sys.InputName = inputvarnames;
62 sys.OutputName = outputvarnames;
63 sys.Notes = obj.description;
64 sys.Name = obj.name;
65 varargout{1} = sys;
66 end
67 end
68
69 %--------------------------------------------------------------------------
70 % Get Info Object
71 %--------------------------------------------------------------------------
72 function ii = getInfo(varargin)
73
74 if nargin == 1 && strcmpi(varargin{1}, 'None')
75 sets = {};
76 pl = [];
77 else
78 sets = {'Default'};
79 pl = getDefaultPlist;
80 end
81 % Build info object
82 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.converter, '$Id: ssm2ss.m,v 1.33 2011/04/08 08:56:23 hewitson Exp $', sets, pl);
83 end
84
85 %--------------------------------------------------------------------------
86 % Get Default Plist
87 %--------------------------------------------------------------------------
88 function pl = getDefaultPlist()
89 pl = plist();
90
91 p = param({'inputs', ['Specify the inputs. Give one of:<ul>'...
92 '<li>A cell-array of input port names.</li>'...
93 '<li>A cell-array of logical arrays specifying which input ports to use for each input block.</li>'...
94 '<li>A cell-array of double values specifying which input ports to use for each input block.<li>'...
95 '<li>The string ''ALL'' to use all inputs.']}, paramValue.STRING_VALUE('ALL'));
96 pl.append(p);
97
98 p = param({'states', 'Specify the states. Specify the states as for the ''inputs'' parameter.'}, paramValue.STRING_VALUE('ALL'));
99 pl.append(p);
100
101 p = param({'outputs', 'Specify the outputs. Specify the outputs as for the ''inputs'' parameter.'}, paramValue.STRING_VALUE('ALL'));
102 pl.append(p);
103 end
104
105
106
107