How do I find the quadratic approximation using this equation?

9 views (last 30 days)
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 Comment
Matt J
Matt J on 6 Mar 2020
Edited: Matt J on 6 Mar 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;

Sign in to comment.

Answers (1)

Matt J
Matt J on 6 Mar 2020
Edited: Matt J on 7 Mar 2020
Consider using this File Exchange tool instead:

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!