diff m-toolbox/classes/+utils/@prog/fields2list.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/+utils/@prog/fields2list.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,36 @@
+function fnames = fields2list(fields)
+% FIELDS2LIST splits a string containing fields seperated by ','
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: FIELDS2LIST splits a string containing fields seperated by
+%              ',' and returns a cell array.
+%
+% CALL:       fnames = fields2list(fields)
+%
+% INPUTS:     string - a string seperated by ','
+%
+% OUTPUTS:    fnames - cell array
+%
+% EXAMPLE:    >> fields = 'field1, field2, field3, field4';
+%             >> ltpda_fields2list(fields)
+%             ans =
+%                   'field1'    ' field2'    ' field3'    ' field4'
+%
+% VERSION: $Id: fields2list.m,v 1.1 2008/06/18 13:35:11 hewitson Exp $
+%
+% HISTORY: 26-01-2007 M Hewitson
+%             Creation
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+fnames = [];
+[f,r] = strtok(fields, ',');
+fnames = [fnames  cellstr(f)];
+while ~isempty(r)
+  [f,r] = strtok(r, ',');
+  fnames = [fnames  cellstr(f)];
+end
+
+
+% END
\ No newline at end of file