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

 採用された回答

Matt J
Matt J 2012 年 12 月 8 日
編集済み: Matt J 2012 年 12 月 8 日

1 投票

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

1 件のコメント

Ren
Ren 2012 年 12 月 8 日
Thanks Matt!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGeoscience についてさらに検索

タグ

質問済み:

Ren
2012 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by