Azzera filtri
Azzera filtri

How to store cell arrays

10 visualizzazioni (ultimi 30 giorni)
Joseph Lee
Joseph Lee il 28 Nov 2017
Modificato: Stephen23 il 28 Nov 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

Risposta accettata

Stephen23
Stephen23 il 28 Nov 2017
Modificato: Stephen23 il 28 Nov 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 Commento
Joseph Lee
Joseph Lee il 28 Nov 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;

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by