Borrar filtros
Borrar filtros

Referring to an element within a cell array element

1 visualización (últimos 30 días)
Ali Kiral
Ali Kiral el 2 de Nov. de 2022
Comentada: Ali Kiral el 2 de Nov. de 2022
x{1}=[1;2;3];
for i=1:4
x{i+1}=x{i}+5;
end
The above small script generates a 1x5 cell array. Every element of x is a 3x1 array. I can see the contents of x using celldisp, for example x{3}=[11;12;13]. Now how do I address, for example, 12, the second element of third element of x?

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 2 de Nov. de 2022
%pre-allocation
x=cell(1,5);
x{1}=[1;2;3];
for i=1:4
x{i+1}=x{i}+5;
end
value=x{3}(2)
value = 12

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by