Stop line after intersection with other line

36 ビュー (過去 30 日間)
Holden Tranquillo
Holden Tranquillo 2021 年 7 月 7 日
コメント済み: Star Strider 2021 年 7 月 7 日
Hello all,
I am trying to figure out how to do this seamingly simple operation easily. I am plotting some ylines and corresponding xlines using interp1 in order to essentially create "crosshairs" at some point. Ideally, only the part of the lines going from an axis to the main line would be showing, not the portions above or to the right. Can anyone think of a simple way to do this? Thanks

採用された回答

Star Strider
Star Strider 2021 年 7 月 7 日
I am not certain what you want. If you want lines to only go an intersection of another line, try something like this —
x = linspace(0, 60);
y = @(x) 20*x; % Equation of Blue Line
figure
plot(x, y(x), '-b', 'LineWidth',2.5)
hold on
x1 = 27;
plot([1 1]*x1, [0 y(x1)], '--g')
plot([0 x1], [1 1]*y(x1), '--r')
hold off
grid
Make appropriate changes to get the result you want for the other lines. Iv you have a vector of independent variable values, consider using a loop.
.
  2 件のコメント
Holden Tranquillo
Holden Tranquillo 2021 年 7 月 7 日
That worked. Thanks!
Star Strider
Star Strider 2021 年 7 月 7 日
As always, my pleasure!

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

その他の回答 (1 件)

Holden Tranquillo
Holden Tranquillo 2021 年 7 月 7 日
I have attached the plot here for easier visibility

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by