How do I find the quadratic approximation using this equation?
Afficher commentaires plus anciens
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 commentaire
We need your X and y. I suggest attaching them in a .mat file. Also, the computation of theta should be,
theta=A\y;
Réponses (1)
Consider using this File Exchange tool instead:
Catégories
En savoir plus sur Physics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!