How not to terminate the polyxpoly loop, when the lines don't intersect?

1 回表示 (過去 30 日間)
Lukasz Zaczek
Lukasz Zaczek 2021 年 3 月 25 日
コメント済み: darova 2021 年 3 月 27 日
V=1;
while V<=21
[xx12(V),yy12(V)] = polyxpoly([x01 x1(V)],[y01 y1(V)],[x02 x2(V)],[y02 y2(V)]);
plot(xx12(V),yy12(V),'o'); axis([-80 80 -10 100]);
pause(1);
V=V+1;
end
Hello. I have a code in which I mark the intersection point of two different lines every second. The loop works fine, but only until the lines actually intersect. For example, when they are parallel, an error 'Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.' occurs, and the loop stops running.
Is there any way, that in this case the loop doesn't terminate, but continues to the next iteration?

採用された回答

darova
darova 2021 年 3 月 26 日
What about if..else statement?
[x,y] = polyxpoly(...);
if ~isempty(x)
% code
end
  3 件のコメント
Lukasz Zaczek
Lukasz Zaczek 2021 年 3 月 27 日
Ok, It worked after a few adjustments, thank you.
darova
darova 2021 年 3 月 27 日
you are welcome

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by