How do I plot this function?
1 view (last 30 days)
Show older comments
I was asked to plot a graph of the function f(x)=y=0.25x^6-2x^5-3x^4+64x^3-212x^2+288x+2 between the interval [-20 20]for which I used the following code:
x=[-20:0.5:20]
y=(0.25*(x.^6))-(2*(x.^5))-(3*(x.^4))+(64*(x.^3))-(212*(x.^2))+(288*x)+2
plot(x,y)
However, the resultant graph did not match the one I created on a basic graph plotter. What could I be doing wrong please? Thanks in advance
2 Comments
Torsten
on 14 May 2022
Edited: Torsten
on 14 May 2022
However, the resultant graph did not match the one I created on a basic graph plotter. What could I be doing wrong please?
Maybe your basic graph plotter is wrong.
At least the code
x = -20:0.5:20;
y = 0.25*x.^6 - 2*x.^5 - 3*x.^4 + 64*x.^3 - 212*x.^2 + 288*x + 2
plot(x,y)
is correct.
Answers (1)
ali temsah
on 14 May 2022
you could plot it like this
x = -20:0.5:20;
coeffents=[0.25 -2 -3 64 -212 288 2];
y=polyval(coeffents,x);
plot(x,y)
grid on
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!