listfields_jd

PURPOSE ^

SYNOPSIS ^

function [varargout] = listfields_jd(s,mode)

DESCRIPTION ^

 This function list the fields of s and its substructures. 
 If mode is true, substructures themselves are ignored is the list.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [varargout] = listfields_jd(s,mode)
0002 %
0003 % This function list the fields of s and its substructures.
0004 % If mode is true, substructures themselves are ignored is the list.
0005 %
0006 if nargin < 2,
0007     mode = 1;
0008 end
0009 %
0010 sfieldnames = fieldnames(s);
0011 %
0012 nfields = length(sfieldnames);
0013 smask = false(1,nfields);
0014 %
0015 for ifield = 1:nfields,
0016     sfieldname = sfieldnames{ifield};
0017     if isstruct(s.(sfieldname)),
0018         sfieldnames = [sfieldnames;listfields_jd(s.(sfieldname),mode)];
0019         if mode,
0020             smask(ifield) = true;
0021         end
0022     end
0023 end
0024 %
0025 sfieldnames(smask) = [];
0026 sfieldnames = unique(sfieldnames);
0027 %
0028 if nargout > 0,
0029     varargout{1} = sfieldnames;
0030 else
0031     disp('List of field names')
0032     disp('-------------------')
0033     disp(' ');
0034     for ifield = 1:length(sfieldnames);
0035         disp(sfieldnames{ifield});
0036     end
0037     disp(' ');
0038 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.