Mercurial > hg > ltpda
comparison m-toolbox/classes/@plist/setPropertyForKey.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 % SETPROPERTY set a property from a specified parameter to a given value. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: set a property from a specified parameter to a given value. | |
5 % If the property name exists then replace the value otherwise | |
6 % add this property. | |
7 % | |
8 % CALL: obj = obj.getProperty(key, propertyName, value); | |
9 % | |
10 % INPUTS: key: Key for the parameter | |
11 % propertyName: Property name of the value | |
12 % value: Value for the property | |
13 % | |
14 % VERSION: $Id: setPropertyForKey.m,v 1.1 2009/07/14 16:13:20 ingo Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function obj = setPropertyForKey(obj, key, propertyName, val) | |
19 | |
20 if nargin ~= 4 | |
21 error('### This method works only with four inputs.'); | |
22 end | |
23 | |
24 for ii = 1:numel(obj.params) | |
25 if strcmpi(obj.params(ii).key, key) | |
26 obj = copy(obj, nargout); | |
27 obj.params(ii).setProperty(propertyName, val); | |
28 break; | |
29 end | |
30 end | |
31 | |
32 end |