how can i make my plot to stop at point and continue after this point?

43 ビュー (過去 30 日間)
omar elbatal
omar elbatal 2020 年 2 月 27 日
回答済み: darova 2020 年 2 月 27 日
i have a matlab assignment that needs a start point and an end point with an obstical between them, i want my path to start from (0,0) and end at (100 100) and the obstical is locatedat (50,50) and it a circle. i want my path to avoid the edge of the circle and continue to (100,100).
its a path of robot that avoids an obstical.
PS im really new to matlab
clear
clc
xs=0;
ys=0;
xg=100;
yg=100;
plot (xs(1), ys(1),'*r');
hold on
plot(xg(1), yg(1),'*b');
r=5;
xo=50;
yo=50;
th = 0:pi/6:2*pi;
xunit = r * cos(th) + xo;
yunit = r * sin(th) + yo;
plot(xunit, yunit);
for n=1:100
plot(n,n,'.k')
if n==45
x
end
end
  2 件のコメント
darova
darova 2020 年 2 月 27 日
You can replace some value with NaN. Plot function breaks line at that place
omar elbatal
omar elbatal 2020 年 2 月 27 日
Can you please guide me through it if its not a problem, please. Thank you

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

回答 (1 件)

darova
darova 2020 年 2 月 27 日
Something like that i think
x = linspace(xs,xg,20);
y = linspace(ys,yg,20);
y(10) = nan;
plot(x,y)
hold on
plot(xunit,yunit)
hold off
The result

カテゴリ

Help Center および File ExchangeROS Toolbox についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by