Brace indexing is not supported for variables of this type.

Hi I need some help. I have created this for loop to extract the images in the different subfolders that are in the given directory in order to process them in another script called Feat_extraction_k. The loop does fine for the first subfolder and the images inside. However, once it reaches the second subfolder the error is displayed for the line with the variable 'Image File' (Brace indexing is not supported for variables of this type) How can I fix this? Thanks.

 Réponse acceptée

Try this:
filePattern = fullfile(pwd, '*.png');
imds = imageDatastore(filePattern)
allFileNames = imds.Files;
numFiles = numel(imds.Files);
for k = 1 : numel(allFileNames)
% Get this file name.
fullFileName = allFileNames{k};
fprintf('Processing %s\n', fullFileName);
end
You can set the top level folder in the first line of the code above by replacing pwd with some folder of your own.

1 commentaire

Thank you so much, this was really helpful! I used this code inside my initial for loop and worked perfectly :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by