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

 Respuesta aceptada

Star Strider
Star Strider el 13 de Nov. de 2017
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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Nov. de 2017

Comentada:

el 13 de Nov. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by