Filter löschen
Filter löschen

How to store cell arrays

10 Ansichten (letzte 30 Tage)
Joseph Lee
Joseph Lee am 28 Nov. 2017
Bearbeitet: Stephen23 am 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

Akzeptierte Antwort

Stephen23
Stephen23 am 28 Nov. 2017
Bearbeitet: Stephen23 am 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 Kommentar
Joseph Lee
Joseph Lee am 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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by