Borrar filtros
Borrar filtros

accessing cell data using brace indexing,

4 visualizaciones (últimos 30 días)
Tijjani Aminu Kuda
Tijjani Aminu Kuda el 27 de En. de 2020
Comentada: Walter Roberson el 29 de Ag. de 2021
Hi everyone,
I am tring to access the content of multiple cell in a loop. I have used the code:
for k = 1:length(predictors)
usg = predictors{k};
end
But it doesn't work. Instead I'm getting error that reads: Brace indexing not supported for this variable type. Could someone help please?

Respuestas (3)

Catalytic
Catalytic el 28 de En. de 2020
You need to check what predictors really is. It is not a cell array, as you believe.

Image Analyst
Image Analyst el 28 de En. de 2020
The error is saying it's not a cell array like you think. It's something else, like a double or something. Where did it come from? Did some other function create it? If so, what?
See the FAQ for a good discussion of cell arrays. This should give you a good idea of where and when to use braces, parentheses, and brackets. Granted, it can be confusing. But I think reading the FAQ will help.

Abdul Rof V
Abdul Rof V el 29 de Ag. de 2021
Editada: Abdul Rof V el 29 de Ag. de 2021
PI=ones(10,10);
p0=0;
for i=1:5
p{i}=PI{i}
end
anything wrong in indexing
  1 comentario
Walter Roberson
Walter Roberson el 29 de Ag. de 2021
You cannot use {} indexing with numeric arrays such as PI is assigned. {} indexing is reserved for container datatypes such as cell arrays or tables or strings.
You need () indexing for numeric datatypes.
Note: your PI is 2 dimensional, but you are using a single index for it. That does have meaning and can be valid, but please make sure it is what you want to do.

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by