How to use a for loop to generate function inputs

1 次查看(过去 30 天)
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.

回答(1 个)

Geoff Hayes
Geoff Hayes 2019-2-23
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[....

标签

Community Treasure Hunt

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

Start Hunting!

Translated by