How to fill closed curves. The code I wrote can't be implemented, I don't know how to correct it, thanks for the answer.

fig = openfig('biaozhunxinyuevv.fig');
fig = gcf;
axObjs = fig.Children;
dataObjs = axObjs.Children;
xt= dataObjs(1).XData;
yt= dataObjs(1).YData;
fill(xt,yt,'r')
plot(xt,yt,'ko')
hold on

답변 (1개)

fig = gcf;
axObjs = fig.Children;
dataObjs = axObjs.Children;
xt= dataObjs(1).XData;
yt= dataObjs(1).YData;
fill(xt,yt,'r')
hold on
plot(xt,yt,'ko')

댓글 수: 4

Thanks a lot for your answer. The result of running your code is still not filled with black, as shown in the picture below.
open('biaozhunxinyuevv.fig');
a = get(gca,'Children');
xdata = get(a, 'XData');
xdata = [xdata{1} xdata{3}] ;
ydata = get(a, 'YData');
ydata = [ydata{1} ydata{3}] ;
patch(xdata,ydata,'r')
You can use your ocde also, but extract (1 and 3) data as shown.
I see, the padding is well implemented, thank you very much for your answer.
Thanks is accepting the answer.. :)

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

카테고리

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

질문:

2022년 3월 11일

댓글:

2022년 3월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by