HELP: Why poly11 fit is not fitting my data?
7 次查看(过去 30 天)
显示 更早的评论
HELLO,
Could you please help me?
I have fitted around 40 surfaces from points, with the same code , all off them fit properly except for this one:
X = [478590; 478430; 478370; 478260; 478210; 478370];
Y= [7429630.703; 7429513.568 ; 7429475.211; 7429388.671; 7429363.763; 7429477.185];
Z= [2302.848; 2221.125; 2250.860; 2196.164; 2270.641; 2119.579];
f=fit([X,Y],Z,'poly11');
figure
plot(f,[X,Y],Z)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291318/image.bmp)
WHY??? If they are very close to a flat plane
What can I do?
I have tried almost all the fit options
(The objective is to fit them to a flat plane to evaluate " coplanarity" with Rsquare)
1 个评论
dpb
2020-5-8
You left out one important piece of information...
Warning: Equation is badly conditioned. Remove repeated data points or try centering and scaling.
> In curvefit.attention/Warning/throw (line 30)
In fit>iLinearFit (line 680)
In fit>iFit (line 391)
In fit (line 116)
回答(1 个)
dpb
2020-5-8
编辑:dpb
2020-5-8
>> zX=(X-mean(X))/std(X);
>> zY=(Y-mean(Y))/std(Y);
>> f=fit([zX,zY],Z,'poly11')
Linear model Poly11:
f(x,y) = p00 + p10*x + p01*y
Coefficients (with 95% confidence bounds):
p00 = 2227 (2124, 2330)
p10 = -78.27 (-2713, 2556)
p01 = 97.4 (-2537, 2732)
>>
Following the suggestion helps significantly in this case.
The algebra is simple enough to transform back to original coefficients--
c=coeffvalues(f); % standardized model coefficients
C=c(1)-c(2)*mean(X)/std(X)-c(3)*mean(Y)/std(Y); % constant coefficient in X,Y
C(2)=c(2)/std(X); % X, Y coefficients
C(3)=c(3)/std(Y);
C =
-7298467.21 -0.58 1.02
>> [f(zX,zY) [ones(size(X)) X Y]*C.']
ans =
2258.28 2258.28
2232.28 2232.28
2228.21 2228.21
2204.21 2204.21
2208.01 2208.01
2230.23 2230.23
>>
I have/had "format bank" on at the moment so only two decimal places shown, but are same to rounding precision, but far more stable estimate of the coefficients.
3 个评论
dpb
2020-5-17
I overlooked that the bounds estimates for p10, p01 are still huge despite the warning going away.
Your data are simply so nearly collinear the model doesn't fit well...
I've got pressing deadline so not able to spend more time right now, sorry, but you could try removing the 3rd or last point which are identically collinear in X and see if that would remove enough to help.
After that would have to delve in deeper than have time for right now.
As for why X,Y not X, it's the independent variables that build the X estimator matrix; Y just shows up on RHS so doesn't really affect solution.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!