Plotting a function and a horizontal line segment

8 ビュー (過去 30 日間)
Andy Parsons
Andy Parsons 2017 年 8 月 15 日
コメント済み: Star Strider 2017 年 8 月 16 日
I need to plot f(x) = -ln(x+0.01)+e^x and g(x)=f(0) from x=0 to the second intercept point. I can plot the f(x) function, I just don't know how to plot both of them together (and how I plot a horizontal line segment). Thanks
  3 件のコメント
Andy Parsons
Andy Parsons 2017 年 8 月 16 日
are you able to elaborate on this? thanks
Star Strider
Star Strider 2017 年 8 月 16 日
See my Answer.

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

回答 (1 件)

Star Strider
Star Strider 2017 年 8 月 15 日
Try this:
f = @(x) exp(x) - log(x+0.01);
x2nd = fzero(@(x) f(x)-f(0), 5); % Find Second ‘x’ At ‘f(0)’
x = linspace(0, 2);
y = f(x);
figure(1)
plot(x, y)
hold on
plot([0 x2nd], f(0)*[1 1], '-r')
hold off
grid

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by