Skip to content

Commit

Permalink
Fix error caused by writecell() trying to write a cell structure with…
Browse files Browse the repository at this point in the history
… missing values
  • Loading branch information
jmgirard committed Nov 11, 2019
1 parent dc94e3f commit f67184a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 10 additions & 9 deletions fig_collect.m
Original file line number Diff line number Diff line change
Expand Up @@ -822,15 +822,16 @@ function timer_Callback(~,~,handles)
{'Second'},{handles.settings.labelX},{handles.settings.labelY},{'Button'}; ...
{'%%%%%%'},{'%%%%%%'},{'%%%%%%'},{'%%%%%%'}; ...
num2cell(mean_ratings)];
% Create export file
try
writecell(output,fullfile(pathname,filename), ...
'FileType','text','Delimiter','comma', ...
'QuoteStrings',true,'Encoding','UTF-8');
msgbox('Export successful.','Success');
catch err
errordlg(err.message,'Error saving');
end
output(cellfun(@(x) any(ismissing(x)), output)) = {''};
% Create export file
try
writecell(output,fullfile(pathname,filename), ...
'FileType','text','Delimiter','comma', ...
'QuoteStrings',true,'Encoding','UTF-8');
msgbox('Export successful.','Success');
catch err
errordlg(err.message,'Error saving');
end
end
program_reset(handles);
% While transitioning or paused
Expand Down
2 changes: 2 additions & 0 deletions fig_review.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function menu_export_Callback(hObject,~)
{'Second'},{handles.labelX},{handles.labelY},{'B'}; ...
{'%%%%%%'},{'%%%%%%'},{'%%%%%%'},{'%%%%%%'}; ...
num2cell([handles.Seconds,handles.MeanRatingsX,handles.MeanRatingsY,zeros(length(handles.Seconds),1)])];
output(cellfun(@(x) any(ismissing(x)), output)) = {''};
%Prompt user for output filepath
[filename,pathname] = uiputfile({'*.csv','Comma-Separated Values (*.csv)'},'Save as',fullfile(handles.settings.defaultdir,defaultname));
if isequal(filename,0), return; end
Expand Down Expand Up @@ -382,6 +383,7 @@ function menu_combine_Callback(hObject,~)
out = [out; append];
waitbar(f/length(filenames),w);
end
out(cellfun(@(x) any(ismissing(x)), out)) = {''};
%Prompt user for output filepath
[outfile,outpath] = uiputfile({'*.csv','Comma-Separated Values (*.csv)'},'Save as',fullfile(handles.settings.defaultdir,'Combined.csv'));
if isequal(outfile,0), return; end
Expand Down

0 comments on commit f67184a

Please sign in to comment.