Brace indexing is not supported for variables of this type.

Hi,
Can anyone guide me, how to correct this error please. Below is the code.
Code:
imgFile = dir('*.jpg') ;
imageNames = length(imgFile)
outputVideo = VideoWriter('test.avi');
outputVideo.FrameRate = 2;
open(outputVideo)
for ii = 1:length(imageNames)
img = imread(imageNames{ii});
writeVideo(outputVideo,img)
end
close(outputVideo)
Error:
Brace indexing is not supported for variables of this type.
Error in ImaVid_Seq (line 12)
img = imread(imageNames{ii});

 Accepted Answer

imageNames = {imgFile.name}

5 Comments

Hi Matt,
It did not resolved the problem. I have 1 to 169 images with name exp_1 till exp_179 but this change in the code not reading the images in sequence, as you can see below. What can I do to make it read images in sequence.
Columns 169 through 174
{'exp_9.jpg'} {'exp_90.jpg'} {'exp_91.jpg'} {'exp_92.jpg'} {'exp_93.jpg'} {'exp_94.jpg'}
This should do it.
imageNames=cellstr("exp_" +(1:179)+".jpg")
classsssssss! thanks alot. is there a document, where i can learn this sort of technique ? rather to use cell string, parenthesis or curly brackets.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!