comparison m-toolbox/m/built_in_models/ssm/ssm_model_SMD.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 % SMD A statespace model of the Spring-Mass-Damper system
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: A statespace model of the Spring-Mass-Damper
5 %
6 % CALL:
7 % HARMONIC_OSC_1D = ssm(plist('built-in','SMD'))
8 %
9 %
10 % OUTPUTS:
11 % - SMD is an SSM object
12 %
13 %
14 % REFERENCES:
15 %
16 %
17 %
18 % INFO:
19 % <a href="matlab:utils.models.displayModelOverview('ssm_model_SMD')">Model Information</a>
20 %
21 %
22 % REFERENCES:
23 %
24 %
25 % VERSION: $Id: ssm_model_SMD.m,v 1.2 2011/04/29 09:48:34 marc1 Exp $
26 %
27 % HISTORY:
28 %
29 %
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
32
33 function varargout = ssm_model_SMD(varargin)
34
35 % Process inputs
36 [info, pl, constructorInfo, fcn] = utils.models.processModelInputs(varargin(:), mfilename, @getModelDescription, @getModelDocumentation, @getVersion, @versionTable);
37 if ~isempty(info)
38 varargout{1} = info;
39 return;
40 end
41
42 % Build the object
43 out = fcn(pl);
44
45 % Set the method version string in the minfo object
46 if ~isempty(constructorInfo)
47 % If this is a user-call via a constructor, then we add history
48 out = addHistoryStep(out, constructorInfo, pl);
49 end
50
51 if nargout > 0
52 varargout{1} = out;
53 varargout{2} = pl;
54 else
55 error('!!! Invalid number of output')
56 end
57 end
58
59
60 %--------------------------------------------------------------------------
61 % AUTHORS EDIT THIS PART
62 %--------------------------------------------------------------------------
63
64 function desc = getModelDescription
65 desc = 'A built-in model that constructs a statespace model for the SMD.';
66 end
67
68 function doc = getModelDocumentation
69 doc = sprintf([...
70 '<br>It constructs a simple spring mass damper test system.<br>\n'...
71 ]);
72 end
73
74 % default version is always the first one
75 function vt = versionTable()
76
77 vt = {...
78 'Standard', @versionStandard, ...
79 };
80
81 end
82
83 % This is the standard SMD model
84 %
85 function varargout = versionStandard(varargin)
86
87 if nargin == 1 && ischar(varargin{1})
88 switch varargin{1}
89 case 'plist'
90
91 % The plist for this version of this model
92 pl = plist();
93
94 pl = combine(pl, ssm.getDefaultPlist('from built-in model'));
95
96 % set output
97 varargout{1} = pl;
98
99 case 'description'
100 varargout{1} = sprintf([...
101 'This is the standard model for the SMD.'
102 ]);
103 case 'info'
104 varargout{1} = [];
105 otherwise
106 error('unknown inputs');
107 end
108 return;
109 end
110
111 % build model
112 pl = varargin{1};
113 %% parameters array
114 paramNames = {'SMD_W' 'SMD_C' 'SMD_S1' 'SMD_S2' 'SMD_B' 'SMD_D1'};
115 paramValues = [0.2 0.5 0 0 1 0];
116 paramUnits = unit('s^-1', 's^-1', '', 's', '', 's^2');
117 paramDescriptions = {'Oscilator eigen-frequency' 'Oscilator damping factor'...
118 'Gain sensing coefficient' 'Gain differential sensing coefficient' ...
119 'Actuator gain' 'Actuation cross sensing coefficient'};
120
121
122
123 % If the user didn't give a 'param names' key to set parameter values,
124 % perhaps they gave individual parameter names
125 pl = ssm.modelHelper_processInputPlist(pl, ssm_model_SMD('plist','Standard'));
126
127 % processing parameters and declaring variables depending on user needs
128 [sys.params, sys.numparams] = ssm.modelHelper_declareParameters(pl, paramNames, paramValues, paramDescriptions, paramUnits);
129
130 % here computation of the system's matrices
131 sys.amats = {[0 1 ; -SMD_W*SMD_W -2*SMD_C*SMD_W]};
132 sys.cmats = {[1+SMD_S1 SMD_S2]};
133 sys.bmats = {[0;SMD_B] [0 0; 1 0]};
134 sys.dmats = {SMD_D1 [0 1]};
135
136 sys.timestep = 0;
137
138 sys.name = 'SRPINGMASSDAMPER';
139 sys.description = 'standard spring-mass-damper test system';
140
141 inputnames = {'CMD' 'DIST_SMD'};
142 inputdescription = {'force noise' 'observation noise'};
143 inputvarnames = {{'F'} {'F' 'S'}};
144 inputvarunits = {unit('kg m s^-2') [unit('kg m s^-2') unit('m')]};
145 inputvardescription = [];
146
147 ssnames = {'SMD'};
148 ssdescription = {'TM position and speed'};
149 ssvarnames = {{'x' 'xdot'}};
150 ssvarunits={[unit('m') unit('m s^-1')]};
151 ssvardescription = [];
152
153 outputnames = {'SMD'};
154 outputdescription = {'observed position'};
155 outputvarnames ={{'OBS'}};
156 outputvarunits={unit('m')};
157 outputvardescription = [];
158
159 %% Build input plist
160 sys.inputs = ssmblock.makeBlocksWithData(inputnames, inputdescription, inputvarnames, inputvarunits, inputvardescription);
161 sys.outputs = ssmblock.makeBlocksWithData(outputnames, outputdescription, outputvarnames, outputvarunits, outputvardescription);
162 sys.states = ssmblock.makeBlocksWithData(ssnames, ssdescription, ssvarnames, ssvarunits, ssvardescription);
163
164 sys = ssm(sys);
165
166 varargout{1} = sys;
167
168 end
169
170
171 %--------------------------------------------------------------------------
172 % AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE
173 %--------------------------------------------------------------------------
174
175
176 %--------------------------------------------------------------------------
177 % Get Version
178 %--------------------------------------------------------------------------
179 function v = getVersion
180
181 v = '$Id: ssm_model_SMD.m,v 1.2 2011/04/29 09:48:34 marc1 Exp $';
182
183 end