0001 function report_corr_table(corr_st, params)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 if ~isfield(params,'delim')
0020 delim = '\t';
0021 else
0022 delim = params.delim;
0023 end
0024
0025 if ~isfield(params,'precision')
0026 precision = 2;
0027 end
0028
0029 if ~isfield(params,'varLabels')
0030 varLabels = {};
0031 else
0032 varLabels = params.varLabels;
0033 end
0034
0035
0036 nvars = size(corr_st.r,1);
0037 nlabels = length(varLabels);
0038 if nlabels ~= nvars
0039 error('Mismatch in number of variables (%d) and variable labels (%d)', nvars, nlabels)
0040 end
0041
0042
0043 if strcmp(delim,',')
0044 fext = '.csv';
0045 else
0046 fext = '.txt';
0047 end
0048 params.fname = fullfile(params.paths.analyses,[params.fstub fext]);
0049 fid = ensemble_init_fid(params);
0050
0051
0052 fprintf(fid,delim);
0053 for ivar = 1:nvars
0054 fprintf(fid,varLabels{ivar});
0055 if ivar < nvars
0056 fprintf(fid,delim);
0057 else
0058 fprintf(fid,'\n');
0059 end
0060 end
0061
0062
0063 fmt_str = sprintf('%%.%df%%s', precision);
0064
0065 for ivar = 1:nvars
0066 fprintf(fid,sprintf('%%s%s',delim),varLabels{ivar});
0067 for jvar = 1:nvars
0068 fprintf(fid,fmt_str,corr_st.r(ivar,jvar),prob2str(corr_st.p(ivar,jvar),0.05,'*',3,false));
0069 if jvar < nvars
0070 fprintf(fid,delim);
0071 else
0072 fprintf(fid,'\n');
0073 end
0074 end
0075 end