Brace indexing is not supported for variables of this type.

4 Ansichten (letzte 30 Tage)
Beatriz
Beatriz am 26 Jan. 2023
Kommentiert: Beatriz am 26 Jan. 2023
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 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.
  1 Kommentar
Beatriz
Beatriz am 26 Jan. 2023
Thank you so much, this was really helpful! I used this code inside my initial for loop and worked perfectly :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by