Filter löschen
Filter löschen

How to use a for loop to generate function inputs

1 Ansicht (letzte 30 Tage)
pldr-bny
pldr-bny am 23 Feb. 2019
Beantwortet: Geoff Hayes am 23 Feb. 2019
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.

Antworten (1)

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by