Error message: Brace indexing is not supported for variables of this type.

1 次查看(过去 30 天)
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?

采纳的回答

Rik
Rik 2019-10-10
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by