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

 Accepted Answer

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 Comments

if I type in the function on a graphing calculator the graph looks different than on matlab
Trust the MATLAB plot!
haha okay thanks
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])

Sign in to comment.

More Answers (0)

Categories

Asked:

on 13 Nov 2017

Commented:

on 13 Nov 2017

Community Treasure Hunt

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

Start Hunting!