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