Skip to content

Commit f67184a

Browse files
committed
Fix error caused by writecell() trying to write a cell structure with missing values
1 parent dc94e3f commit f67184a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

fig_collect.m

+10-9
Original file line numberDiff line numberDiff line change
@@ -822,15 +822,16 @@ function timer_Callback(~,~,handles)
822822
{'Second'},{handles.settings.labelX},{handles.settings.labelY},{'Button'}; ...
823823
{'%%%%%%'},{'%%%%%%'},{'%%%%%%'},{'%%%%%%'}; ...
824824
num2cell(mean_ratings)];
825-
% Create export file
826-
try
827-
writecell(output,fullfile(pathname,filename), ...
828-
'FileType','text','Delimiter','comma', ...
829-
'QuoteStrings',true,'Encoding','UTF-8');
830-
msgbox('Export successful.','Success');
831-
catch err
832-
errordlg(err.message,'Error saving');
833-
end
825+
output(cellfun(@(x) any(ismissing(x)), output)) = {''};
826+
% Create export file
827+
try
828+
writecell(output,fullfile(pathname,filename), ...
829+
'FileType','text','Delimiter','comma', ...
830+
'QuoteStrings',true,'Encoding','UTF-8');
831+
msgbox('Export successful.','Success');
832+
catch err
833+
errordlg(err.message,'Error saving');
834+
end
834835
end
835836
program_reset(handles);
836837
% While transitioning or paused

fig_review.m

+2
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ function menu_export_Callback(hObject,~)
322322
{'Second'},{handles.labelX},{handles.labelY},{'B'}; ...
323323
{'%%%%%%'},{'%%%%%%'},{'%%%%%%'},{'%%%%%%'}; ...
324324
num2cell([handles.Seconds,handles.MeanRatingsX,handles.MeanRatingsY,zeros(length(handles.Seconds),1)])];
325+
output(cellfun(@(x) any(ismissing(x)), output)) = {''};
325326
%Prompt user for output filepath
326327
[filename,pathname] = uiputfile({'*.csv','Comma-Separated Values (*.csv)'},'Save as',fullfile(handles.settings.defaultdir,defaultname));
327328
if isequal(filename,0), return; end
@@ -382,6 +383,7 @@ function menu_combine_Callback(hObject,~)
382383
out = [out; append];
383384
waitbar(f/length(filenames),w);
384385
end
386+
out(cellfun(@(x) any(ismissing(x)), out)) = {''};
385387
%Prompt user for output filepath
386388
[outfile,outpath] = uiputfile({'*.csv','Comma-Separated Values (*.csv)'},'Save as',fullfile(handles.settings.defaultdir,'Combined.csv'));
387389
if isequal(outfile,0), return; end

0 commit comments

Comments
 (0)