comparison m-toolbox/classes/+utils/@helper/class2plist.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 % CLASS2PLIST create a plist from the class properties.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: CLASS2PLIST create a plist from the class properties.
5 %
6 % CALL: pl = class2plist('class_name');
7 % pl = class2plist(obj);
8 %
9 % VERSION: $Id: class2plist.m,v 1.2 2008/08/05 16:27:28 ingo Exp $
10 %
11 % HISTORY: 15-04-2008 M Hewitson
12 % Creation
13 %
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15
16 function pl = class2plist(varargin)
17
18 props = properties(varargin{1});
19
20 if isobject(varargin{1})
21 obj = varargin{1};
22 elseif ischar(varargin{1})
23 obj = feval(varargin{1});
24 else
25 error('### Unknown input.');
26 end
27
28 pl = plist();
29
30 % Loop over properties
31 for jj=1:length(props)
32 % get property
33 p = props{jj};
34 pl.append(p, obj.(p));
35 end
36
37 end
38