Brace indexing is not supported for variables of this type.
3 views (last 30 days)
Show older comments
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.

0 Comments
Accepted Answer
Image Analyst
on 26 Jan 2023
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.
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!