How to specify an x-range for a yline?

83 ビュー (過去 30 日間)
Harr
Harr 2021 年 3 月 22 日
コメント済み: Harr 2021 年 3 月 22 日
we have the following code;
x = -2:0.25:2;
[X,Y] = meshgrid(x);
Z = X.*exp(-X.^2-Y.^2);
contour(X,Y,Z,30)
yl = yline(0,'--','y = 0','LineWidth',3);
It returns the following graph:
How to specify a range for the line? for example if i want to see the line only between x=-1 to x=1?

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 22 日
You cannot do that with yline() . You need to line() or plot() the line into place, and text() the label into place.
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 3 月 22 日
plot([x1; x2], [y; y], 'LineWidth',3)
Harr
Harr 2021 年 3 月 22 日
Thankl you very much ^_^

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by