How do I extract an array from struct?

조회 수: 2 (최근 30일)
Jacopo Zini
Jacopo Zini 2022년 6월 18일
댓글: Rahin Vadsariya 2022년 7월 5일
Hi all,
I have struct (X) which contains differe elemets including duoble and cell. I would like to extract one array from a cell (xaxis) which is 2x2x2.
I have tried with the function vertcat as following:
MyMatrix = vertcat(X.xaxis)
and I obrain a matrix 2x2x2 cell which contains the following elements:
val(:,:,1) =
{[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 … ]} {'A}
{[ 200.5358 201.1543 201.7728 202.6154 … ]} {'B' }
val(:,:,2) =
{[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 … ]} {'A'}
{[ 537.8697 537.8876 537.9055 537.9298 … ]} {'C' }
I would like to extract B, do you have any suggestion?
I have tried with: Shift=cell2mat(MyMatrix) but i got "Error using cell2mat (line 45) All contents of the input cell array must be of the same data type."
Thanks for your help!
  댓글 수: 3
Chris Burschyk
Chris Burschyk 2022년 6월 18일
I guess you need to index with curly brackets. X{2,1,1} would be cell with the values for B.
Rahin Vadsariya
Rahin Vadsariya 2022년 7월 5일
Hello,
Can you please provide a sample struct and what you are trying to extract from that struct?

댓글을 달려면 로그인하십시오.

답변 (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