0001 function analysis_txt2file(as,fname)
0002
0003
0004
0005
0006
0007
0008
0009
0010 td = as.txt;
0011
0012 nsubs = length(td.subid);
0013 nquest = length(td.qid);
0014
0015 max_stims = size(td.data,3);
0016
0017 fid = fopen(fname,'wt');
0018 fprintf(fid,'Question\tSubject\tStimID\tResponse\n');
0019 for iq = 1:nquest
0020 fprintf(fid,'\n%s\n',td.qtxt{iq});
0021 for isub = 1:nsubs
0022 fprintf(fid,'\n\t%s\n', td.subid{isub});
0023 for istim = 1:max_stims
0024 if td.niter(isub,iq) && ~isempty(td.data{isub,iq,istim})
0025 if ~isempty(td.stimidx)
0026 stim_id = as.stims.ids(td.stimidx(isub,istim));
0027 stim_str = sprintf('%d', stim_id);
0028 else
0029 stim_str = '';
0030 end
0031 fprintf(fid,'\t\t%s\t%s\n', stim_str, td.data{isub,iq,istim});
0032 end
0033 end
0034 end
0035 end
0036 fclose(fid);
0037
0038 return