Hi. I'm trying to plot a polynomial function but I'm not getting the desired output. Can you tell me what I'm doing wrong?

1 view (last 30 days)
The original question is: and I need to plot it over an interval of (-2:1). My code is :
and my output is:
whereas my desired output is:
I'm not sure what I'm doing wrong
  3 Comments
John D'Errico
John D'Errico on 27 Sep 2021
Edited: John D'Errico on 27 Sep 2021
Of course, what @William Rose said SHOULD have been an answer. I can't rectify that, not yet at least. :)
See that what you did was to plot FOUR points on that curve, then connected by default with straight lines. You want to plot a zillion points on that curve, so use what was suggested to you by @William Rose.

Sign in to comment.

Answers (1)

William Rose
William Rose on 27 Sep 2021
replace
x=-2:1;
with
x=-2:.01:1;
to get a step size of .01, instead of a step size of 1.
Good luck!

Categories

Find more on Graphics Performance 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!