Mercurial > hg > ltpda
comparison m-toolbox/m/mdcs/mdc1/models/ltpda_mdc1_dynamics.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 % LTPDA_MDC1_DYNAMICS returns a frequency-domain model of the dynamics for MDC1. | |
2 % | |
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
4 % | |
5 % DESCRIPTION: LTPDA_MDC1_DYNAMICS returns a frequency-domain model of the dynamics | |
6 % for MDC1. | |
7 % | |
8 % CALL: b = ltpda_mdc1_dynamics(pl) | |
9 % | |
10 % PARAMETERS: | |
11 % | |
12 % 'Omega2' - the square of the stiffness term for the dynamical response | |
13 % [default: 1.3e-6] | |
14 % 'f' - a vector of frequencies [default: 1] | |
15 % or | |
16 % 'f1' - start frequency [default: 1e-6] | |
17 % 'f2' - stop frequency [default: 5] | |
18 % 'nf' - number of frequency points [default: 1000] | |
19 % 'scale' - frequency spacing, 'lin' or 'log' [default: 'log'] | |
20 % | |
21 % VERSION: $Id: ltpda_mdc1_dynamics.m,v 1.4 2008/08/12 12:33:25 anneke Exp $ | |
22 % | |
23 % The following call returns a parameter list object that contains the | |
24 % default parameter values: | |
25 % | |
26 % >> pl = ltpda_mdc1_dynamics(ao, 'Params') | |
27 % | |
28 % The following call returns a string that contains the routine CVS version: | |
29 % | |
30 % >> version = ltpda_mdc1_dynamics(ao,'Version') | |
31 % | |
32 % The following call returns a string that contains the routine category: | |
33 % | |
34 % >> category = ltpda_mdc1_dynamics(ao,'Category') | |
35 % | |
36 % HISTORY: 11-04-08 M Hewitson | |
37 % Creation | |
38 % | |
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
40 function varargout = ltpda_mdc1_dynamics(varargin) | |
41 %%% Check if this is a call for parameters | |
42 if utils.helper.isinfocall(varargin{:}) | |
43 varargout{1} = getInfo(varargin{3}); | |
44 return | |
45 end | |
46 | |
47 %%% Collect input variable names | |
48 in_names = cell(size(varargin)); | |
49 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
50 | |
51 pli = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
52 | |
53 %%% Decide on a deep copy or a modify | |
54 %%% REMARK: If you create a new AO (call the constructor) then | |
55 %%% it is not necessay to copy the input-AOs !!!!!!!!!!!!!!!!!!!!!!!!! | |
56 | |
57 | |
58 %%% Combine plists | |
59 pl = combine(pli, getDefaultPlist('Range')); | |
60 | |
61 %% Extract parameters from plist | |
62 | |
63 f = find(pl, 'f'); | |
64 if isempty(f) | |
65 f1 = find(pl, 'f1'); | |
66 f2 = find(pl, 'f2'); | |
67 nf = find(pl, 'nf'); | |
68 scale = find(pl, 'scale'); | |
69 | |
70 switch scale | |
71 case 'lin' | |
72 f = linspace(f1, f2, nf); | |
73 case 'log' | |
74 f = logspace(log10(f1), log10(f2), nf); | |
75 end | |
76 end | |
77 | |
78 omega2 = find(pl, 'Omega2'); | |
79 | |
80 %% Compute response for frequencies f | |
81 | |
82 varargout{1} = getDynamics(f, omega2); | |
83 end | |
84 %-------------------------------------------------------------------------- | |
85 % Get DF controller for each frequency | |
86 function o = getDynamics(f, w2) | |
87 | |
88 % We take abs() here and use +- omega later | |
89 w1 = sqrt(abs(w2)); | |
90 | |
91 % DF dynamics | |
92 pl = plist('gain',(w1*w1), 'poles', [], 'zeros', [pz(w1/2/pi) pz(-w1/2/pi)]); | |
93 dfm = pzmodel(pl); | |
94 | |
95 % Make an AO from the pzmodel | |
96 o = resp(dfm, plist('f', f)) ; | |
97 o.setName('s^2+\omega^2'); | |
98 o.addHistory(getInfo,plist('Omega2', w2),[],o.hist); | |
99 end | |
100 | |
101 function ii = getInfo(varargin) | |
102 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
103 sets = {}; | |
104 pls = []; | |
105 elseif nargin == 1&& ~isempty(varargin{1}) && ischar(varargin{1}) | |
106 sets{1} = varargin{1}; | |
107 pls = getDefaultPlist(sets{1}); | |
108 else | |
109 sets = {'List', 'Range'}; | |
110 pls = []; | |
111 for kk=1:numel(sets) | |
112 pls = [pls getDefaultPlist(sets{kk})]; | |
113 end | |
114 end | |
115 % Build info object | |
116 ii = minfo(mfilename, 'MDC1', '', 'Signal Processing', '$Id: ltpda_mdc1_dynamics.m,v 1.4 2008/08/12 12:33:25 anneke Exp $', sets, pls); | |
117 end | |
118 | |
119 function plo = getDefaultPlist(set) | |
120 switch set | |
121 case 'List' | |
122 plo = plist('Omega2', 1.3e-6, 'f', [1]); | |
123 case 'Range' | |
124 plo = plist('Omega2', 1.3e-6, ... | |
125 'f1', 1e-6,... | |
126 'f2', 5,... | |
127 'nf', 1000,... | |
128 'scale', 'log'); | |
129 otherwise | |
130 plo = plist(); | |
131 end | |
132 end |