Polyfit for 0 order polynomial

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

 Akzeptierte Antwort

Matt J
Matt J am 8 Dez. 2012
Bearbeitet: Matt J am 8 Dez. 2012

1 Stimme

It's legitimate, but it's also far simpler to do
p=mean(y);

Weitere Antworten (0)

Kategorien

Mehr zu Geoscience finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

Ren
am 8 Dez. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by