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