Prevent putting a cell array inside another cell array

8 vues (au cours des 30 derniers jours)
Jacob Kelley
Jacob Kelley le 21 Oct 2019
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

Réponse acceptée

Jacob Kelley
Jacob Kelley le 21 Oct 2019
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.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by