Prevent putting a cell array inside another cell array

8 ビュー (過去 30 日間)
Jacob Kelley
Jacob Kelley 2019 年 10 月 21 日
回答済み: Jacob Kelley 2019 年 10 月 21 日
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

採用された回答

Jacob Kelley
Jacob Kelley 2019 年 10 月 21 日
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 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by