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
It's legitimate, but it's also far simpler to do
p=mean(y);

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Polynomials 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by