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.
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 Exchange에서 Line 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