필터 지우기
필터 지우기

The inconsistency of polyfit function

조회 수: 1 (최근 30일)
Aleksy Barski
Aleksy Barski 2019년 10월 8일
답변: Stephan 2019년 10월 8일

x=[1,2,3,4,5];
y=3*x.^2+7*x+12;
p1=plifit(x,y,2);
[p2,S]=polyfit(x,y,2);
[p3,S,mu]=polyfit(x,y,2);
p1
p2
p3
Why p3 not same as p2 and p1

답변 (1개)

Stephan
Stephan 2019년 10월 8일
From the documentation:
[p,S,mu] = polyfit(x,y,n) also returns mu, which is a two-element vector with centering and scaling values. mu(1) is mean(x), and mu(2) is std(x). Using these values, polyfit centers x at zero and scales it to have unit standard deviation.
also in the related example:
Use polyfit with three outputs to fit a 5th-degree polynomial using centering and scaling, which improves the numerical properties of the problem. polyfit centers the data in year at 0 and scales it to have a standard deviation of 1, which avoids an ill-conditioned Vandermonde matrix in the fit calculation.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by