Delete parts of plotted figures?

19 ビュー (過去 30 日間)
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2020 年 10 月 23 日
コメント済み: Star Strider 2020 年 10 月 28 日
I have made this image
with this code:
axis equal
hold on
caca=2*pi();
ang=linspace(0,caca);
xp=5*cos(ang);
yp=5*sin(ang);
circ=[xp;yp];
plot(xp,yp,'r');
L1=[-8 8; 3 3];
plot(L1(1,:),L1(2,:),'b')
And I want to delete the part of the line within the circle and the part of the circle under the line so the image results like this:
Is there any way of achieving that? How can I do it?

採用された回答

Star Strider
Star Strider 2020 年 10 月 23 日
Try this:
axis equal
hold on
caca=2*pi();
ang=linspace(0,caca);
xp=5*cos(ang);
yp=5*sin(ang);
circ=[xp;yp];
L1x = linspace(-8, 8);
L1y = 3*ones(size(L1x));
L1=[L1x; L1y]; % Re-define Line
incirc = inpolygon(L1x,L1y,circ(1,:),circ(2,:));
L1(1,incirc) = NaN;
L1(2,incirc) = NaN;
plot(xp(yp>=3),yp(yp>=3),'r');
plot(L1(1,:),L1(2,:),'b')
.
  4 件のコメント
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2020 年 10 月 28 日
thanks!
Star Strider
Star Strider 2020 年 10 月 28 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 10 月 23 日
use patch() or fill()? This one does part of it.
patch(xp,yp,'white')
  1 件のコメント
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2020 年 10 月 25 日
I have tried that and appears and strange figure with black borders

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by