How to use a for loop to generate function inputs

1 visualización (últimos 30 días)
pldr-bny
pldr-bny el 23 de Feb. de 2019
Respondida: Geoff Hayes el 23 de Feb. de 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.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 23 de Feb. de 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[....

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by