fit an equation to data

Hi, I would like to find the six coefficients a,b,c,d, e and f of the equation z=a+b*x+c*y+d*x^2+e*x*y+f*y^2 to fit data contained in the matrix A=3x6 (with first row : z values, second row: x values and third row : y values)
Thank you very much

Answers (1)

Star Strider
Star Strider on 27 Jul 2015
Edited: Star Strider on 27 Jul 2015
The easiest way:
z = A(1,:);
x = A(2,:);
y = A(3,:);
B = [ones(size(z(:))) x(:) y(:) x(:).^2 x(:).*y(:) y(:).^2]\z(:);
a = B(1)
b = B(2)
c = B(3)
d = B(4)
e = B(5)
f = B(6)

Categories

Find more on Curve Fitting Toolbox in Help Center and File Exchange

Asked:

on 27 Jul 2015

Edited:

on 27 Jul 2015

Community Treasure Hunt

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

Start Hunting!