Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/scatterData.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 % SCATTERDATA Creates from the y-values of two input AOs an new AO(xydata) | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SCATTERDATA This method creates from the y-values of the | |
5 % input AOs a new AO with xydata. The y-values of the first | |
6 % input will be the x-values of the new AO and the y-values of | |
7 % the second AO will be the y-values of the new AO. | |
8 % | |
9 % CALL: b = scatterData(a1, a2, pl) | |
10 % | |
11 % INPUTS: aN - input analysis objects (two) | |
12 % pl - input parameter list | |
13 % | |
14 % OUTPUTS: b - output analysis object | |
15 % | |
16 % Possible actions: | |
17 % | |
18 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'scatterData')">Parameters Description</a> | |
19 % | |
20 % VERSION: $Id: scatterData.m,v 1.8 2011/04/08 08:56:16 hewitson Exp $ | |
21 % | |
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
23 | |
24 function varargout = scatterData(varargin) | |
25 | |
26 %%% Check if this is a call for parameters | |
27 if utils.helper.isinfocall(varargin{:}) | |
28 varargout{1} = getInfo(varargin{3}); | |
29 return | |
30 end | |
31 | |
32 import utils.const.* | |
33 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
34 | |
35 % Collect input variable names | |
36 in_names = cell(size(varargin)); | |
37 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
38 | |
39 % Collect all AOs | |
40 [as, ao_invars,rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
41 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
42 | |
43 %%% Combine plists | |
44 pl = combine(pls, getDefaultPlist); | |
45 | |
46 % Check number of input AOs | |
47 if numel(as) ~= 2 | |
48 error('### This method can only handle two input AOs'); | |
49 end | |
50 | |
51 % Check the length of both AOs | |
52 if (len(as(1)) ~= len(as(2))) | |
53 error('### The length of both input AOs must be the same'); | |
54 end | |
55 | |
56 a1 = as(1); | |
57 a2 = as(2); | |
58 | |
59 xy = xydata(); | |
60 xy.setY(a2.y); | |
61 xy.setDy(a2.dy); | |
62 xy.setYunits(a2.yunits); | |
63 xy.setX(a1.y); | |
64 xy.setDx(a1.dy); | |
65 xy.setXunits(a1.yunits); | |
66 | |
67 bs = ao(xy); | |
68 bs.name = sprintf('scatterData(%s, %s)', a1.name, a2.name); | |
69 bs.description = [a1.description, ' ', a2.description]; | |
70 | |
71 bs.addHistory(getInfo('None'), pl, ao_invars, [a1.hist a2.hist]); | |
72 | |
73 % Set output | |
74 if nargout == numel(bs) | |
75 % List of outputs | |
76 for ii = 1:numel(bs) | |
77 varargout{ii} = bs(ii); | |
78 end | |
79 else | |
80 % Single output | |
81 varargout{1} = bs; | |
82 end | |
83 end | |
84 | |
85 | |
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
87 % Local Functions % | |
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
89 %-------------------------------------------------------------------------- | |
90 % Get Info Object | |
91 %-------------------------------------------------------------------------- | |
92 function ii = getInfo(varargin) | |
93 | |
94 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
95 sets = {}; | |
96 pl = []; | |
97 else | |
98 sets = {'Default'}; | |
99 pl = getDefaultPlist; | |
100 end | |
101 % Build info object | |
102 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: scatterData.m,v 1.8 2011/04/08 08:56:16 hewitson Exp $', sets, pl); | |
103 end | |
104 | |
105 %-------------------------------------------------------------------------- | |
106 % Get Default Plist | |
107 %-------------------------------------------------------------------------- | |
108 function plout = getDefaultPlist() | |
109 persistent pl; | |
110 if exist('pl', 'var')==0 || isempty(pl) | |
111 pl = buildplist(); | |
112 end | |
113 plout = pl; | |
114 end | |
115 | |
116 function pl = buildplist() | |
117 pl = plist.EMPTY_PLIST; | |
118 end | |
119 |