フィルターのクリア

plotting graphs in matlab

1 回表示 (過去 30 日間)
Elliott Cameron
Elliott Cameron 2020 年 4 月 25 日
コメント済み: Elliott Cameron 2020 年 4 月 26 日
Hello
If i had the following
clear
clc
x=0:10
y=-2*x+6
y1=3*x
plot(x,y)
hold on
plot(x,y1)
how would i just plot the graph with the limits being the x and y intercept
  7 件のコメント
dpb
dpb 2020 年 4 月 25 日
@Tommy...you have/are developing my habit of putting Answers in Comments... :)
Tommy
Tommy 2020 年 4 月 25 日
Ah! Yes I agree... I do often question if I really understand what's being asked, and whether my "answer" is a full answer, but too often I default to the comment section

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

採用された回答

Tommy
Tommy 2020 年 4 月 25 日
You can solve for the intercepts using the equation for y1 and update the axes limits accordingly:
clear
clc
x=0:10;
y1=-2*x+6;
y=3*x;
plot(x,y)
hold on
plot(x,y1)
yint = 6; % -2*0 + 6 => 6
xint = 3; % (0 - 6)/(-2) => 3
ax = gca;
ax.XLim(2) = xint;
ax.YLim(2) = yint;
  1 件のコメント
Elliott Cameron
Elliott Cameron 2020 年 4 月 26 日
brilliant thats perfect, thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by