Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@plist/setPropertyForKey.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,32 @@ +% SETPROPERTY set a property from a specified parameter to a given value. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: set a property from a specified parameter to a given value. +% If the property name exists then replace the value otherwise +% add this property. +% +% CALL: obj = obj.getProperty(key, propertyName, value); +% +% INPUTS: key: Key for the parameter +% propertyName: Property name of the value +% value: Value for the property +% +% VERSION: $Id: setPropertyForKey.m,v 1.1 2009/07/14 16:13:20 ingo Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function obj = setPropertyForKey(obj, key, propertyName, val) + + if nargin ~= 4 + error('### This method works only with four inputs.'); + end + + for ii = 1:numel(obj.params) + if strcmpi(obj.params(ii).key, key) + obj = copy(obj, nargout); + obj.params(ii).setProperty(propertyName, val); + break; + end + end + +end