필터 지우기
필터 지우기

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