How to get field value from a struct as a variable in order to use in a code?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey all
I want to extract x and y from this struct, as a seperate variables in my workplace, in order to use them in my code.
struct with fields:
Geometry: 'Polygon'
BoundingBox: [2×2 double]
X: [1×125458 double]
Y: [1×125458 double]
please help me
thanks a lot
댓글 수: 0
채택된 답변
Guillaume
2019년 10월 17일
There's no need to. Creating separate variables is usually not a good idea. Wherever you were going to use X, use yourstruct.X. Makes no difference to the code.
댓글 수: 0
추가 답변 (2개)
James Tursa
2019년 10월 17일
Depends on your downstream code whether this is really worth it, but simply e.g.
x = yourstruct.x;
y = yourstruct.y;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!