Borrar filtros
Borrar filtros

How to store cell arrays

10 visualizaciones (últimos 30 días)
Joseph Lee
Joseph Lee el 28 de Nov. de 2017
Editada: Stephen23 el 28 de Nov. de 2017
If cell arrays contains matrices, what contains cell arrays? Is it possible to store different cell arrays into a single data set?
Eg.
A= {[1 2 3] [1 2] [3]
[1 ] [2 3] [1 2 3]};
B= {[4 5 6] [4 5] [6]
[4 ] [5 6] [4 5 6]};
C(1)=A
C(2)=B

Respuesta aceptada

Stephen23
Stephen23 el 28 de Nov. de 2017
Editada: Stephen23 el 28 de Nov. de 2017
You can put cell arrays into any container variables, in particular:
  • cell arrays
  • structures
Here are two cell arrays nested inside another cell array:
C{1} = {1,2,3};
C{2} = {'blue','anna'};
Note that cell arrays have two different kinds of indexing:
  1. {} curly braces are used to access the contents of the cells.
  2. () parentheses are used to reference the cells themselves.
See the MATLAB documentation:
  1 comentario
Joseph Lee
Joseph Lee el 28 de Nov. de 2017
Is there a different way to use struct compared to cells or matrix?
I tried the same way but it does not work.
C=struct;
C(1)=A;
Assignment between unlike types is not allowed.
Error in Untitled6 (line 24)
C(1)=A;

Iniciar sesión para comentar.

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