필터 지우기
필터 지우기

How to plot a struct with 2 fields in Matlab

조회 수: 6 (최근 30일)
Hamed Bolandi
Hamed Bolandi 2019년 7월 17일
편집: Hamed Bolandi 2019년 7월 18일
I have T=81x4 struct, each member has two fields (x and y cordinate). I want to plot each row which will be 4 nodes to make a rectangular by connecting the nodes. Totally it should be 81 rectangular. I am wondering how can I plot each row of struct with 2 fields. I would appreciate if anyone can help me.
for i=1:81
plot(T(i,:).x,T(i,:).y,'.')
xlim([-50 50]);
ylim([-50 50]);
k = boundary(x,y);
hold on;
plot(x(k),y(k));
end

채택된 답변

Bruno Luong
Bruno Luong 2019년 7월 17일
Try this
x=reshape([T(:).x],size(T));
y=reshape([T(:).y],size(T));
plot(x(:,[1:end 1])',y(:,[1:end 1])')
  댓글 수: 1
Hamed Bolandi
Hamed Bolandi 2019년 7월 17일
편집: Hamed Bolandi 2019년 7월 18일
Thank you so much Bruno. It worked.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by