How to use a for loop to generate function inputs
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to create an image set from a folder containing 81 subfolders. With three subfolders, '01', '02', '03', this is trivial using the code below:
imgSets = img[imageSet(fullfile(rootfolder,'01')),imageSet(fullfile(rootfolder,'02')), imageSet(fullfile(rootfolder,'03'))];
However, I do not want to specify these paths manually in the 81 folder case. I was able to use a for loop to generate the correct string, but that was very hacky and clearly not best practice. Could anyone help with a function/for loop to achieve this or point me in the right direction for a better solution?
Thank you in advance.
0 Kommentare
Antworten (1)
Geoff Hayes
am 23 Feb. 2019
pldr-bny - you could try something like
numberOfImageSets = 81;
imgSets = cell(numberOfImageSets,1);
for k = 1:numberOfImageSets
imgSets{k, 1} = imageSet(fullfile(rootfolder,sprintf('%02d',k)));
end
That might not be exactly what you want...I'm not sure (don't understand) the usage behind the
imgSets = img[....
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!