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

1 visualización (últimos 30 días)
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?

Respuesta aceptada

Rik
Rik el 10 de Oct. de 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.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by