Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/ztrans.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 % ZTRANS implements continuous z-domain Z-transform for smodel objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: ZTRANS implements continuous z-domain Z-transform for smodel objects. | |
5 % | |
6 % CALL: obj = ztrans(mdl, var) | |
7 % obj = mdl.ztrans(var) | |
8 % obj = mdl.ztrans(in_var, ret_var) [Please note the order!] | |
9 % obj = mdl.ztrans(plist('ret_var', ret_var, 'in_var', in_var)) | |
10 % obj = mdl.ztrans(pl) | |
11 % | |
12 % INPUTS: mdl - input smodels | |
13 % ret_var - a string with a variable name to transform into | |
14 % in_var - a string with a variable name to transform with respect to | |
15 % pl - input parameter list | |
16 % | |
17 % OUTPUTS: obj - output smodel(s) | |
18 % | |
19 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'ztrans')">Parameters Description</a> | |
20 % | |
21 % VERSION: $Id: ztrans.m,v 1.10 2011/04/08 08:56:30 hewitson Exp $ | |
22 % | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 | |
25 function varargout = ztrans(varargin) | |
26 | |
27 % Settings | |
28 operatorName = 'ztrans'; | |
29 | |
30 % Check if this is a call for parameters | |
31 if utils.helper.isinfocall(varargin{:}) | |
32 varargout{1} = getInfo(varargin{3}); | |
33 return | |
34 end | |
35 | |
36 % Check if the method was called by another method | |
37 callerIsMethod = utils.helper.callerIsMethod; | |
38 | |
39 % Collect input variable names | |
40 in_names = cell(size(varargin)); | |
41 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
42 | |
43 % Collect all smodels and plists | |
44 [as, smodel_invars, rest] = utils.helper.collect_objects(varargin(:), 'smodel', in_names); | |
45 [pl, pl_invars, rest] = utils.helper.collect_objects(rest(:), 'plist', in_names); | |
46 | |
47 % Decide on a deep copy or a modify | |
48 mdls = copy(as, nargout); | |
49 | |
50 % Combine input plists and default PLIST | |
51 pl = parse(pl, getDefaultPlist()); | |
52 | |
53 % Select the variable to transform with respect to: | |
54 [in_var, ret_var, pl] = utils.helper.process_smodel_transf_options(pl, rest); | |
55 | |
56 % Check the independent variable | |
57 if isempty(in_var) | |
58 in_var = as.xvar; | |
59 end | |
60 | |
61 if isempty(in_var) | |
62 error(['### Please specify the independent variable to transform with respect to, ' ... | |
63 'or set the xvar properties of the model(s)!']); | |
64 end | |
65 | |
66 % If the method was called by another method, we do not need to set history. | |
67 % As such, the info object can be empty | |
68 if callerIsMethod | |
69 infoObj = []; | |
70 else | |
71 infoObj = getInfo('None'); | |
72 end | |
73 | |
74 % Apply the method to all models | |
75 mdls.sop(callerIsMethod, smodel_invars, operatorName, {in_var, ret_var}, pl, infoObj); | |
76 | |
77 % Set units | |
78 if strcmp(in_var, as.xvar) | |
79 setYunits(mdls, mdls.yunits .* mdls.xunits); | |
80 setXunits(mdls, 1 ./ mdls.xunits); | |
81 end | |
82 | |
83 % Set output | |
84 varargout{1} = mdls; | |
85 | |
86 end | |
87 | |
88 %-------------------------------------------------------------------------- | |
89 % Get Info Object | |
90 %-------------------------------------------------------------------------- | |
91 function ii = getInfo(varargin) | |
92 | |
93 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
94 sets = {}; | |
95 pls = []; | |
96 else | |
97 sets = {'Default'}; | |
98 pls = getDefaultPlist(); | |
99 end | |
100 % Build info object | |
101 ii = minfo(mfilename, 'smodel', 'ltpda', utils.const.categories.op, '$Id: ztrans.m,v 1.10 2011/04/08 08:56:30 hewitson Exp $', sets, pls); | |
102 ii.setArgsmin(1); | |
103 end | |
104 | |
105 %-------------------------------------------------------------------------- | |
106 % Get Default Plist | |
107 %-------------------------------------------------------------------------- | |
108 function plout = getDefaultPlist() | |
109 persistent pl; | |
110 if ~exist('pl', 'var') || isempty(pl) | |
111 pl = buildplist(); | |
112 end | |
113 plout = pl; | |
114 end | |
115 | |
116 function pl = buildplist() | |
117 pl = plist(); | |
118 | |
119 % Ret_Var | |
120 p = param({'ret_var', 'Return variable, to transform into.'}, paramValue.STRING_VALUE('z')); | |
121 pl.append(p); | |
122 | |
123 % In_Var | |
124 p = param({'in_var', ['Independent variable, to transform with respect to.<br>' ... | |
125 'If left empty, the x variable of the model(s) will be used']}, paramValue.STRING_VALUE('')); | |
126 pl.append(p); | |
127 | |
128 end |