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...

 Akzeptierte Antwort

Star Strider
Star Strider am 13 Nov. 2017

0 Stimmen

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 Kommentare

MaraBoj
MaraBoj am 13 Nov. 2017
if I type in the function on a graphing calculator the graph looks different than on matlab
Star Strider
Star Strider am 13 Nov. 2017
Trust the MATLAB plot!
MaraBoj
MaraBoj am 13 Nov. 2017
haha okay thanks
Star Strider
Star Strider am 13 Nov. 2017
My pleasure.
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])

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by