Refraining part of the function on the graph, while keeping the interval

1 回表示 (過去 30 日間)
Maxtron Moon
Maxtron Moon 2019 年 5 月 15 日
回答済み: Star Strider 2019 年 5 月 15 日
I'm new in Matlab, and I'm not sure if you can do this in Matlab.
So, I obtained two solutions to a physics problem, of the simple form:
y=-x-95.07 and
y=10/7*x+18.67
which have an intersection. Now, due to an extra physical condition, only the
part on the left side of the interaction make physicial sense, so, I would like to
create a plot that doesn't show the right side of the interaction, so basicly I want the
lines to appear up to a point, while the interval on the x-axis goes beyond that point!

採用された回答

Star Strider
Star Strider 2019 年 5 月 15 日
Try this:
y1 = @(x) -x-95.07;
y2 = @(x) 10/7*x+18.67;
xint = fzero(@(x)y1(x)-y2(x), 1); % Intersection
x = linspace(xint-10, xint);
figure
plot(x, y1(x), x, y2(x))
grid
xlim([xint-10 xint+10])
producing:
Refraining part of the function on the graph, while keeping the interval - 2019 05 15.png
Experiment to get the result you want.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by