Curve fitting(toolbox) 3d plot is different when using surf

3 vues (au cours des 30 derniers jours)
Christian York
Christian York le 27 Fév 2022
Commenté : Christian York le 28 Fév 2022
I use the curve fitting toolbox and is was what I get:
However, when I try to use 'surf' to plot the 3d plot above it turns out:
[Xtest1, Xtest2] = meshgrid(xtest1, xtest2);
p00 = -0.4888 ;
p10 = 0.04507 ;
p01 = 0.1304 ;
p20 = 0.005239 ;
p11 = -0.01134 ;
p02 = -0.009979 ;
p30 = 0.0005176 ;
p21 = 0.0002514 ;
p12 = 0.0005639 ;
p03 = 0.0002402 ;
z = p00 + p10.*Xtest1 + p01.*Xtest2 + p20.*Xtest1.^2 + p11.*Xtest1.*Xtest2 + p02.*Xtest1.^2 + p30.*Xtest1.^3 + p21.*Xtest1.^2.*Xtest2 + p12.*Xtest1.*Xtest2.^2 + p03.*Xtest2.^3;
surf(Xtest1,Xtest2,z)
The plot using 'surf' is not as same as the plot from curve fitting toolbox at all. Apparently the maximum in curve fitting toolbox and surf plot are different. The data xtest1 and xtest2 are same for both curve fitting toolbox and meshgrid, I wonder what is wrong with the code above?

Réponse acceptée

Matt J
Matt J le 27 Fév 2022
Modifié(e) : Matt J le 27 Fév 2022
It looks like you have transcribed the fitted coefficients manually from the display, and only to 4 decimal places. (It also looks like you might have interchanged xtest1 with xtest2.)
The more reliable thing to do would be to save the fit tot the Matlab workspace, and then use the fit object to Evaluate the Surface Fit.
  11 commentaires
Matt J
Matt J le 28 Fév 2022
No, I've revised my code above to use meshgrid(). There is still very close agreement.
Christian York
Christian York le 28 Fév 2022
Yeah, the problem is I use the 'meshgrid' incorrectly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by