Mercurial > hg > ltpda
comparison m-toolbox/classes/@stattest/setData.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 % SETDATA Set the data vector. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Set the data vector. | |
5 % | |
6 % CALL: obj.setData(data); | |
7 % obj = obj.setData(data); create copy of the object | |
8 % | |
9 % INPUTS: obj - must be a stattest object. | |
10 % data - a vector of ltpda user objects. | |
11 % | |
12 % <a href="matlab:utils.helper.displayMethodInfo('stattest', 'setData')">Parameters Description</a> | |
13 % | |
14 % VERSION: $Id: setData.m,v 1.3 2011/04/08 08:56:38 hewitson Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = setData(varargin) | |
19 | |
20 %%% Check if this is a call for parameters | |
21 if utils.helper.isinfocall(varargin{:}) | |
22 varargout{1} = getInfo(varargin{3}); | |
23 return | |
24 end | |
25 | |
26 %%% Internal call: Only one object + don't look for a plist | |
27 if strcmp(varargin{end}, 'internal') | |
28 | |
29 %%% decide whether we modify the first object, or create a new one. | |
30 varargin{1} = copy(varargin{1}, nargout); | |
31 if iscell(varargin{2}) | |
32 varargin{1}.data = varargin{2}; | |
33 else | |
34 in = varargin{2}; | |
35 data = {}; | |
36 for kk=1:numel(in) | |
37 data = [data {in(kk)}]; | |
38 end | |
39 end | |
40 varargout{1} = varargin{1}; | |
41 return | |
42 end | |
43 | |
44 %%% Collect input variable names | |
45 in_names = cell(size(varargin)); | |
46 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
47 | |
48 [objs, obj_invars, rest] = utils.helper.collect_objects(varargin(:), '', in_names); | |
49 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
50 | |
51 %%% If pls contains only one plist with the single key 'data' then set the | |
52 %%% property with a plist. | |
53 if length(pls) == 1 && isa(pls, 'plist') && nparams(pls) == 1 && isparam(pls, 'data') | |
54 rest{1} = find(pls, 'data'); | |
55 end | |
56 | |
57 if numel(rest) > 1 || isempty(rest) | |
58 error('### Please specify data array, either in a plist or directly.'); | |
59 end | |
60 | |
61 %%% Combine plists | |
62 pls = combine(pls, plist('data', rest{1})); | |
63 | |
64 %%% Set the 'xunits' | |
65 for ii = 1:numel(objs) | |
66 | |
67 %%% decide whether we modify the input stattest object, or create a new one. | |
68 objs(ii) = copy(objs(ii), nargout); | |
69 | |
70 %%% set the value | |
71 objs(ii).data = rest{1}; | |
72 objs(ii).addHistory(getInfo('None'), pls, obj_invars(ii), objs(ii).hist); | |
73 end | |
74 | |
75 %%% Set output | |
76 if nargout == numel(objs) | |
77 % List of outputs | |
78 for ii = 1:numel(objs) | |
79 varargout{ii} = objs(ii); | |
80 end | |
81 else | |
82 % Single output | |
83 varargout{1} = objs; | |
84 end | |
85 end | |
86 | |
87 | |
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
89 % Local Functions % | |
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
91 | |
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
93 % | |
94 % FUNCTION: getInfo | |
95 % | |
96 % DESCRIPTION: Get Info Object | |
97 % | |
98 % HISTORY: 11-07-07 M Hewitson | |
99 % Creation. | |
100 % | |
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
102 | |
103 function ii = getInfo(varargin) | |
104 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
105 sets = {}; | |
106 pl = []; | |
107 else | |
108 sets = {'Default'}; | |
109 pl = getDefaultPlist; | |
110 end | |
111 % Build info object | |
112 ii = minfo(mfilename, 'stattest', 'ltpda', utils.const.categories.helper, '$Id: setData.m,v 1.3 2011/04/08 08:56:38 hewitson Exp $', sets, pl); | |
113 end | |
114 | |
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
116 % | |
117 % FUNCTION: getDefaultPlist | |
118 % | |
119 % DESCRIPTION: Get Default Plist | |
120 % | |
121 % HISTORY: 11-07-07 M Hewitson | |
122 % Creation. | |
123 % | |
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
125 | |
126 function plout = getDefaultPlist() | |
127 persistent pl; | |
128 if exist('pl', 'var')==0 || isempty(pl) | |
129 pl = buildplist(); | |
130 end | |
131 plout = pl; | |
132 end | |
133 | |
134 function pl = buildplist() | |
135 pl = plist(); | |
136 | |
137 % Xunits | |
138 p = param({'data', 'The array of LTPDA user objects to set as the data for this test.'}, paramValue.EMPTY_DOUBLE); | |
139 pl.append(p); | |
140 | |
141 end | |
142 |