Mercurial > hg > ltpda
comparison m-toolbox/classes/@plist/isparam.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 % ISPARAM look for a given key in the parameter lists. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: ISPARAM look for a given key in the parameter lists. Exist the key | |
5 % in the parameter list then is the result 1 otherwise 0. | |
6 % The output size have the same numer as the numer of the input | |
7 % plists. | |
8 % | |
9 % CALL: res = isparam(pl, 'key') | |
10 % res = isparam(pl1, pl2, 'key') | |
11 % | |
12 % <a href="matlab:utils.helper.displayMethodInfo('plist', 'isparam')">Parameters Description</a> | |
13 % | |
14 % VERSION: $Id: isparam.m,v 1.16 2011/04/08 08:56:21 hewitson Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = isparam(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 [objs, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist'); | |
27 | |
28 %%%%%%%%%% Some plausibility checks %%%%%%%%%% | |
29 if numel(rest) ~= 1 | |
30 error('### Please specify only one ''key''.'); | |
31 end | |
32 | |
33 if ~ischar(rest{1}) | |
34 error('### The ''key'' must be a string but it is from the class %s.', class(rest{1})); | |
35 end | |
36 | |
37 res = zeros(size(objs)); | |
38 key = rest{1}; | |
39 | |
40 for ii = 1:numel(objs) | |
41 | |
42 pl = objs(ii); | |
43 | |
44 for jj = 1:length(pl.params) | |
45 if strcmpi(pl.params(jj).key, key) | |
46 res(ii) = 1; | |
47 break | |
48 end | |
49 end | |
50 end | |
51 | |
52 varargout{1} = res; | |
53 end | |
54 | |
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
56 % Local Functions % | |
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
58 | |
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
60 % | |
61 % FUNCTION: getInfo | |
62 % | |
63 % DESCRIPTION: Get Info Object | |
64 % | |
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
66 | |
67 function ii = getInfo(varargin) | |
68 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
69 sets = {}; | |
70 pl = []; | |
71 else | |
72 sets = {'Default'}; | |
73 pl = getDefaultPlist; | |
74 end | |
75 % Build info object | |
76 ii = minfo(mfilename, 'plist', 'ltpda', utils.const.categories.helper, '$Id: isparam.m,v 1.16 2011/04/08 08:56:21 hewitson Exp $', sets, pl); | |
77 ii.setModifier(false); | |
78 ii.setArgsmin(1); | |
79 end | |
80 | |
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
82 % | |
83 % FUNCTION: getDefaultPlist | |
84 % | |
85 % DESCRIPTION: Get Default Plist | |
86 % | |
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
88 | |
89 function plo = getDefaultPlist() | |
90 plo = plist(); | |
91 end | |
92 |