Polyfit not showing a curve
Show older comments
Trying to plot a curve using polyfit. This is my code.
% store coordinates
x = [5.2 5.5 5.6 5.8];
y = [6.408 16.125 19.816 27.912];
% use polyfit to get coefficients of cubic
p = polyfit(x, y, 3);
scatter(x, y, 'black');
hold on
plot(p, 'green');
When plotted, p is jagged and looks nothing like a cubic
Accepted Answer
More Answers (1)
Categories
Find more on Polynomials 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!