plot and fit surface

12 vues (au cours des 30 derniers jours)
laura bagnale
laura bagnale le 25 Mai 2021
Commenté : laura bagnale le 9 Juin 2021
Hello everyone,
I hope that someone can help me.
I'm trying to plot several points in the space and to fit them so I can get an mathematical formula like this topic "Fit and Plot a Polynomial Surface"
I want to get a quadratic polynomial so I'm trying to use 'poly22' function. This is my code:
X = [0; 1; 1; -1; -1; 0.3]
Y = [0; 1 ; -1; -1; 1; 0.5]
Z = [0.9; 0.3; 0; 0.2; 0.6; 1]
z = Z;
fitsurface=fit([X,Y],z, 'poly22','Normalize','on')
plot(fitsurface, [X,Y],z)
I obtained this results:
Linear model Poly22:
fitsurface(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
where x is normalized by mean 0.05 and std 0.9028
and where y is normalized by mean 0.08333 and std 0.9174
p00 = 0.9097
p10 = -0.2332
p01 = 0.2645
p20 = -1.07
p11 = -0.02071
p02 = 0.5786
But I am not sure about them and the syntax.
Could you help me please?
Thank you a lot!

Réponse acceptée

Mahesh Taparia
Mahesh Taparia le 4 Juin 2021
The syntax and code which you have used is correct. The above code will fit a 2nd degree polynomial to the given data points and this is what you need.
  17 commentaires
Walter Roberson
Walter Roberson le 9 Juin 2021
When you have a minimization problem, analytic solutions are best unless they would take an undue amount of time.
(There are some minimization problems that can be approached probabilisticly to get a likely solution in a relatively short time, but proving that the answer is the best possible might take a long time. There is a famous mathematical problem involving one of the largest numbers ever invented, literally too large to write down in this universe... for a situation where it is suspected that the real minimum is 6. So sometimes it really does not pay to do a complete analysis. But in a situation like the function you have, you might as well go for the analysis and so be sure that you have the right solution.
laura bagnale
laura bagnale le 9 Juin 2021
I understand.
Thank you very much for the quick answers, the explanation and the support!
Kind Regards,

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by