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

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Rik
Rik il 10 Ott 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.

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by