Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/map3D.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 % MAP3D maps the input 1 or 2D AOs on to a 3D AO | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: MAP3D maps the input 1 or 2D AOs on to a 3D AO. | |
5 % | |
6 % The inputs AOs should be all either 1 or 2D. For 1D inputs, they should | |
7 % all be the same length. For 2D inputs, they should all have the same | |
8 % length. | |
9 % | |
10 % CALL: bs = map3D(a1,a2,a3,...,pl) | |
11 % bs = map3D(as,pl) | |
12 % | |
13 % INPUTS: aN - input analysis objects | |
14 % as - input analysis objects array | |
15 % pl - input parameter list | |
16 % | |
17 % OUTPUTS: bs - array of analysis objects, one for each input | |
18 % | |
19 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'map3D')">Parameters Description</a> | |
20 % | |
21 % VERSION: $Id: map3D.m,v 1.2 2011/11/18 10:33:51 hewitson Exp $ | |
22 % | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 | |
25 | |
26 function varargout = map3D(varargin) | |
27 | |
28 callerIsMethod = utils.helper.callerIsMethod; | |
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 import utils.const.* | |
37 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
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 AOs | |
44 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
45 | |
46 % Decide on a deep copy or a modify | |
47 bs = copy(as, nargout); | |
48 | |
49 % Apply defaults to plist | |
50 usepl = applyDefaults(getDefaultPlist, varargin{:}); | |
51 | |
52 % Check for type | |
53 if isa(bs(1).data, 'cdata') | |
54 nDim = 1; | |
55 nX = bs(1).len; | |
56 elseif isa(bs(1).data, 'data2D') | |
57 nDim = 2; | |
58 nX = length(bs(1).x); | |
59 else | |
60 error('map3D accepts only 1 and 2D input AOs'); | |
61 end | |
62 | |
63 for kk=2:numel(bs) | |
64 if isa(bs(kk).data, 'cdata') && nDim ~= 1 | |
65 error('map3D needs either 1D or 2D inputs, but not mixed'); | |
66 elseif isa(bs(kk).data, 'data2D') && nDim ~= 2 | |
67 error('map3D needs either 1D or 2D inputs, but not mixed'); | |
68 elseif ~isa(bs(kk).data, 'cdata') && ~isa(bs(kk).data, 'data2D') | |
69 error('map3D accepts only 1 and 2D input AOs'); | |
70 end | |
71 | |
72 if nDim == 1 | |
73 if bs(kk).len ~= nX | |
74 error('All input AOs must be of the same length'); | |
75 end | |
76 else | |
77 if length(bs(kk).x) ~= nX | |
78 error('All input AOs must be of the same length'); | |
79 end | |
80 end | |
81 | |
82 end | |
83 | |
84 | |
85 if nDim == 1 | |
86 | |
87 z = bs.y; | |
88 x = 1:bs(1).len; | |
89 y = 1:numel(bs); | |
90 | |
91 xunits = 'Index'; | |
92 yunits = 'Index'; | |
93 zunits = bs(1).yunits; | |
94 | |
95 else | |
96 | |
97 z = bs.y; | |
98 x = bs(kk).x; | |
99 y = 1:numel(bs); | |
100 | |
101 xunits = bs(1).xunits; | |
102 yunits = 'Index'; | |
103 zunits = bs(1).yunits; | |
104 | |
105 end | |
106 | |
107 % Output data | |
108 do = xyzdata(x, y, z.'); | |
109 do.setXunits(xunits); | |
110 do.setYunits(yunits); | |
111 do.setZunits(zunits); | |
112 | |
113 a = ao(); | |
114 a.data = do; | |
115 % name | |
116 name = 'map3D('; | |
117 for kk=1:numel(bs) | |
118 name = [name sprintf('%s,', ao_invars{kk})]; | |
119 end | |
120 name = [name(1:end-1) ')']; | |
121 a.name = name; | |
122 | |
123 % Add history | |
124 if ~callerIsMethod | |
125 a.addHistory(getInfo('None'), usepl, ao_invars, [bs.hist]); | |
126 end | |
127 | |
128 % Set output | |
129 varargout = utils.helper.setoutputs(nargout, a); | |
130 end | |
131 | |
132 %-------------------------------------------------------------------------- | |
133 % Get Info Object | |
134 %-------------------------------------------------------------------------- | |
135 function ii = getInfo(varargin) | |
136 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
137 sets = {}; | |
138 pl = []; | |
139 else | |
140 sets = {'Default'}; | |
141 pl = getDefaultPlist(); | |
142 end | |
143 % Build info object | |
144 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: map3D.m,v 1.2 2011/11/18 10:33:51 hewitson Exp $', sets, pl); | |
145 end | |
146 | |
147 %-------------------------------------------------------------------------- | |
148 % Get Default Plist | |
149 %-------------------------------------------------------------------------- | |
150 function plout = getDefaultPlist() | |
151 persistent pl; | |
152 if ~exist('pl', 'var') || isempty(pl) | |
153 pl = buildplist(); | |
154 end | |
155 plout = pl; | |
156 end | |
157 | |
158 function pl = buildplist() | |
159 | |
160 % General plist for Welch-based, linearly spaced spectral estimators | |
161 pl = plist(); | |
162 | |
163 end | |
164 |