How to store cell arrays

10 次查看(过去 30 天)
Joseph Lee
Joseph Lee 2017-11-28
编辑: Stephen23 2017-11-28
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

采纳的回答

Stephen23
Stephen23 2017-11-28
编辑:Stephen23 2017-11-28
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 个评论
Joseph Lee
Joseph Lee 2017-11-28
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;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by