Error message: Brace indexing is not supported for variables of this type.
1 view (last 30 days)
Show older comments
Adolfo Tortolero Langarica
on 10 Oct 2019
Commented: Adolfo Tortolero Langarica
on 10 Oct 2019
Hello!
The script I am trying to run has previously run well in earlier versions of Matlab without any problem. However, now that I am using Matlab 2019b, the script stops at the first step with the following error message:
Brace indexing is not supported for variables of this type.
Error in bkgsub (line 53)
cnb1=imread([pathname filename{1}]); % Reading images
The code it refers to is the following one, the error is in italiks:
[filename, pathname ] = uigetfile(...
{'*.*';'*.bmp';'*.tif';'*.jpg';'*.jpeg';'*.png';'*.gif';'*.cur';'*.ico';'*.pcx';...
'*.jp2';'*.jpf';'*.jpx';'*.j2c';'*.j2k';'*.pbm';'*.fts';'*.hdf';'*.pgm';...
'*.pnm';'*.ppm';'*.ras';'*.xwd'},'Select the original image and its background','MultiSelect','on');
cnb1=imread([pathname filename{1}]); % Reading images
cnb2=imread([pathname filename{2}]); %
Does anyone knows why this has previously worked (I have run it myself) but now it shows errors?
0 Comments
Accepted Answer
Rik
on 10 Oct 2019
The uigetfile function only returns a cell array if the user actually selects multiple files. The person writing the code should check if this is the case, instead of assuming it in later code.
Never blindly trust user input.
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!