MATLAB: ERROR SELECTING MULTIPLE FILES

for loopguiimport fileload filesmatlab guisave fileuigetfile

HI!
i have attached as much information as possible
so i have written a code to open a text file selected by user and to do whatever based on what the user chooses. this is the code that works.
[file, path] = uigetfile('.txt');
if isequal (file, 0)
disp ('user selected cancel')
else
disp(['user selected', fullfile(path,file)]);
end
COP = importdata(fullfile(path,file));
code works, no worries.
NOW the issue i am having is when the user wants to select and import multiple files. i have tried to do it using a for loop but it opens a structure and i dont know how to handle a struct. the loop i followed is similar to the one found in this link.. https://au.mathworks.com/matlabcentral/answers/71197-error-in-uigetfile-multiselect . so before anyone comes at me for not "trying" i have also tried stringcat and a lot of other methods, none of which worked.
its spits out this error
Error using importdata (line 139)
Unable to open file.
Error in 'trying' (line 13)
COP = importdata(fullfile(path,file));
COULD someone please provide some insight into why this is happening???? or what is wrong with my loop?
if you have nothing helpful to say please just don't say it. thanks.
sincerely a desperate student.

Best Answer

The moment you select multiple files, file becomes a cell array.
Just run this in your command window and select a few files to see the data formats. Don't put ";" so you see how it looks.
[file, path] = uigetfile("Select something", 'MultiSelect', 'on')
You cannot make a fullfile of file, because it is no longer a string, but a cell array. Of course, Matlab cannot concatenate path (a string) with file (a cell array).
This means you will have to loop through your array and use something like
fullfile(path, file{1})
By the way, the answer you so nicely link in your question, contains the above information if you would read Jan's answer carefully.