0001 function txt = vb_struct2str(S)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 txt = fieldnames(S);
0012
0013 names = fieldnames(S);
0014 Nmembers = length(names);
0015
0016
0017 max_name_len = 0;
0018 for k=1:Nmembers
0019 if max_name_len < length(names{k})
0020 max_name_len = length(names{k});
0021 end
0022 end
0023
0024
0025 format = ['%' num2str(max_name_len) 's: %s'];
0026
0027 for i = 1:length(txt);
0028 member = S.(names{i});
0029
0030 if iscell(member)
0031 cell_str = '{';
0032 for k=1:length(member)
0033 child_member = member{k};
0034 if iscell(child_member)
0035
0036 cell_str = [cell_str, ' ', '''{ cell }'''];
0037 else
0038
0039 cell_str = [cell_str, ' ', '''', num2str(child_member), ''''];
0040 end
0041 end
0042 cell_str = [cell_str, ' }'];
0043 txt{i} = sprintf(format, names{i}, cell_str);
0044 else
0045 if isstruct(member), continue; end
0046
0047 txt{i} = sprintf(format, names{i}, num2str(member));
0048 end
0049 end;