How do I find the quadratic approximation using this equation?

I'm trying to find quadratic approximation using the equation:
y = c1*x1^2+ c2*x1*x2+c3*x2^2+a1*x1+a2*x2+b
This equation receives a sampling plan from X = [x1' x2'], observed values y and predicts a quadratic approximation using the above equation. I understand I need to find coefficients first. So far I have gotten here:
X = lhsdesign(20,2)*4-2;
%plot((X(:,1)),(X(:,2)),"*")
%grid on
theta = [c1 c2 c3 a1 a2 b];
A = [(X(:,1))^2, (X(:,1)^2.*(X(:,2))^2,(X(:,2))^2, (X(:,1)),(X(:,2), 1]'
theta = (A'*A)\(A'*y)
There seems to be a problem with matrix A. I have been getting errors about it. Can someone please help me?

1 comentario

Matt J
Matt J el 6 de Mzo. de 2020
Editada: Matt J el 6 de Mzo. de 2020
We need your X and y. I suggest attaching them in a .mat file. Also, the computation of theta should be,
theta=A\y;

Iniciar sesión para comentar.

Respuestas (1)

Categorías

Más información sobre Mathematics and Optimization en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 6 de Mzo. de 2020

Editada:

el 7 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by