how to get this graph to plot correctly?

f(x) = x^8 − 5x^4 + e^x − 7
I've tried f=@(x)x.^8 - 5*x.^4 + exp(x) - 7; and setting x = [-5:0.1:5]; and then just using the plot function, but it doesnt seem right...

 採用された回答

Star Strider
Star Strider 2017 年 11 月 13 日

0 投票

This works for me:
f=@(x)x.^8 - 5*x.^4 + exp(x) - 7;
x = [-5:0.1:5];
plot(x, f(x))
It is essentially your code. What ‘doesn’t seem right’ about the plot?

5 件のコメント

MaraBoj
MaraBoj 2017 年 11 月 13 日
if I type in the function on a graphing calculator the graph looks different than on matlab
Star Strider
Star Strider 2017 年 11 月 13 日
Trust the MATLAB plot!
MaraBoj
MaraBoj 2017 年 11 月 13 日
haha okay thanks
Star Strider
Star Strider 2017 年 11 月 13 日
My pleasure.
Steven Lord
Steven Lord 2017 年 11 月 13 日
You won't see much detail by default because the limits on the Y axis span a wide range of values. 5^8 is near 400000, while 0^8 is 0. You'd need to zoom into the plot or change the axis limits to see the detail for small values of x.
axis([-2 2 -20 20])

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

質問済み:

2017 年 11 月 13 日

コメント済み:

2017 年 11 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by