MATLAB: Is it possible to construct the code below

function

% --- Executes on button press in Calculate.
function Calculate_Callback(~, ~, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ExPath1 = get(handles.Filename1, 'string');
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(ExPath1,'True',63,handles);
ExPath2 = get(handles.Filename2, 'string');
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(ExPath2,'True',63,handles)
ExPath3 = get(handles.Filename3, 'string');
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(ExPath3,'True',63,handles)
ExPath4 = get(handles.Filename4, 'string');
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(ExPath4,'True',63,handles)
ExPath5 = get(handles.Filename5, 'string');
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(ExPath5,'True',63,handles)
ExPath6 = get(handles.Filename6, 'string');
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(ExPath6,'True',63,handles)
I ask, because when i select various files and press calculate the matlab program does not work. However, when I select one file at a time; the program runs with no problem.

Best Answer

You did not answer my question about the mechanism for selecting multiple files, so I will make a guess that you use uigetfile() with Multiselect On and store the result in handles.Filename1 string property.
% --- Executes on button press in Calculate.
function Calculate_Callback(~, ~, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
paths = cellstr(get(handles.Filename1, 'string'));
if length(paths) == 1
paths = get([handles.Filename1, handles.Filename2, handles.Filename3, handles.Filename4, handles.Filename5, handles.Filename6], 'string');
end
for K = 1 : length(paths)
[x, x_1, x_2, x_3, x_4, x_5] = correctionModelworking1(paths{K},'True',63,handles);
end