Polyfit for 0 order polynomial

9 views (last 30 days)
Ren
Ren on 8 Dec 2012
Dear all,
I am trying to plot a horizontal line (y=b and b is a constant) which is the least-square fitting to a set of data. Is that legit to set 'n' in polyfit as 0, say p = polyfit(x, y, 0) to have a horizontal least square fitting line?
Thanks, Ren

Accepted Answer

Matt J
Matt J on 8 Dec 2012
Edited: Matt J on 8 Dec 2012
It's legitimate, but it's also far simpler to do
p=mean(y);

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!