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);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Geoscience에 대해 자세히 알아보기

태그

질문:

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