0001 function [data_table,column_titles] = dsDataField2Table (data,fieldname,verbose_flag)
0002
0003
0004
0005
0006 if nargin < 3
0007 verbose_flag = 0;
0008 end
0009
0010
0011 for i = 1:length(data)
0012 if ~isfield(data(i),'varied')
0013 data(i).varied = [];
0014 end
0015 if isempty(data(i).varied)
0016 data(i).varied = {'Varied1'};
0017 data(i).Varied1 = i;
0018 end
0019 end
0020
0021
0022 varied=data(1).varied;
0023 num_varied=length(varied);
0024 num_sims=length(data);
0025
0026
0027 for j=1:num_varied
0028 if isnumeric(data(1).(varied{j}))
0029 params{j} = [data.(varied{j})];
0030 else
0031 for i = 1:length(data)
0032 params{j}{i} = data(i).(varied{j});
0033 end
0034 end
0035 end
0036
0037
0038 z=0;
0039 num_alllabels = 1;
0040 for i = 1:num_sims
0041 for k = 1:num_alllabels
0042
0043 z=z+1;
0044 data_linear{z} = data(i).(fieldname);
0045
0046
0047 for j = 1:num_varied
0048 if isnumeric(data(1).(varied{j})); ax{j}(z) = params{j}(i);
0049 else
0050 ax{j}{z} = params{j}{i};
0051 end
0052 end
0053 end
0054 end
0055
0056 ax_names = varied;
0057
0058
0059
0060 data_linear = data_linear(:);
0061 for i = 1:length(ax)
0062 ax{i} = ax{i}';
0063 end
0064
0065
0066 data_table = horzcat({data_linear},ax);
0067
0068
0069 column_titles = {'data',ax_names{:}};
0070
0071 if verbose_flag
0072 previewTable(data_table,column_titles);
0073 end
0074
0075 end