How to access data from "Structure within structures" ?

I am beginner I have structure "Sdata" of struct. Which Contains 10 struct. From these every struct, How can I extract 3rd and 4th value?

 채택된 답변

Stephen23
Stephen23 2016년 2월 26일
편집: Stephen23 2016년 2월 26일
If every field has the same size, then this will work:
M = vertcat(Sdata.BoundingBox);
M(:,3:4)
And here is a simple example of it being used. First define some fake data in a 1x3 structure:
>> S(1).B = [8,9,Inf,NaN];
>> S(2).B = [4,5,6,7];
>> S(3).B = [0,1,2,3];
then extract the 3rd and 4th columns of every field:
>> M = vertcat(S.B);
>> M(:,3:4)
ans =
Inf NaN
6 7
2 3
Read this to know how it works:

댓글 수: 1

Avnish Patel
Avnish Patel 2016년 2월 26일
편집: Avnish Patel 2016년 2월 26일
Thanks Stephen, It work. Thanks for quick reply.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

제품

질문:

2016년 2월 26일

편집:

2016년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by