필터 지우기
필터 지우기

Create a cell array containing the first 3 doubles from another cell array

조회 수: 1 (최근 30일)
Hello,
I have a cell araay CCC (500x1 cell), containing 500x1 doubles.
I would like to create a new cell array (a) with just the first three doubles (500x1 each) from CCC.
I tried with a = {CCC{1}:CCC{3}}; but is not working, how can I do it?
Thanks in advance for the help :)

채택된 답변

Garmit Pant
Garmit Pant 2022년 7월 5일
편집: Garmit Pant 2022년 7월 5일
Hello Fabio
It is my understanding that you want to extract the first three cells from a cell array CCC.
This can be achieved using the following code snippet:
a = CCC(1:3);
You can consult the following example to see the effects of the command listed above.
c3 = {[1 ; 2 ; 3 ; 4] [1 ; 2 ; 3 ; 4] [1 ; 2 ; 3 ; 4] [1 ; 2; 3; 4; 5]}
c3 = 1×4 cell array
{4×1 double} {4×1 double} {4×1 double} {5×1 double}
c4 = c3(1:3)
c4 = 1×3 cell array
{4×1 double} {4×1 double} {4×1 double}

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2022년 7월 5일
Would:
ThreeFirst = cell2mat(CCC(1:3));
do the trick?

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by