MATLAB Answers

0

Prevent putting a cell array inside another cell array

Asked by Jacob Kelley on 21 Oct 2019 at 22:48
Latest activity Answered by Jacob Kelley on 21 Oct 2019 at 23:16
So I am trying to make one big cell array with multiple filenames in them that uses a while loop to "append" these filenames to a cell array. I use the uigetfile() to get the file names but also allow the MultiSelect. If the user does select multiple files in one of the loops, it adds a cell array of all those filenames into one cell of an overall cell array. is there a way to make it only one big cell array?
NHxlsx = {};
AddNH = questdlg('Add Non-Host(s)?','','Yes','No','Yes');
while strcmpi(AddNH, 'Yes')
NHxlsx{end+1} = uigetfile('*.xlsx','New Non-Host File(s)','MultiSelect', 'on'); %#ok<*SAGROW>
AddNH = questdlg('Add More Non-Host?','','Yes','No','Yes');
end
So say on the first loop it askes for files and I select 4 files and on the second loop I give it 3 files, then end the loop. Instead of creating a 2x1 cell array with a 4x1 cell array in the first cell and a 3x1 cell array in the second cell, I want it to just make a 7x1 cell array.
Also note: I might have to add the path for the files selected with [file, path] = uigetfile(... so I'm not sure how this will affect it

  0 Comments

Sign in to comment.

Products


Release

R2018b

1 Answer

Answer by Jacob Kelley on 21 Oct 2019 at 23:16
 Accepted Answer

Actually I figured it out. Instead of:
NHxlsx{end+1} = uigetfile('*.xlsx','New Non-Host File(s)','MultiSelect', 'on');
I used this:
NHxlsx = [NHxlsx, uigetfile('*.xlsx','New Non-Host File(s)','MultiSelect', 'on')];
Now I need to figure out how to add the path.

  0 Comments

Sign in to comment.