HELP: Why poly11 fit is not fitting my data?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)
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 comentario
dpb
el 8 de Mayo de 2020
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)
Respuestas (1)
dpb
el 8 de Mayo de 2020
Editada: dpb
el 8 de Mayo de 2020
>> 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 comentarios
dpb
el 17 de Mayo de 2020
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.
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!