From: Samuel on
Hi All,

I have searched through the Matlab forums, but haven't found the answer to my question. I would like to use a least squares function to fit some data.

Briefly, I have two equations of the form

Z1 = a + b*x + c*y + d*x*y
Z2 = e + f*x + g*y + h*x*y

where i know Z1, Z2, x, and y and they're in vector form. I have a few hundred data points, so the lack of data is not an issue. Is there a way I can use the lsqcurvefit function to figure out a thru h or is this a more complex problem?
From: Roger Stafford on
"Samuel " <srp215(a)gmail.com> wrote in message <hteu35$i4n$1(a)fred.mathworks.com>...
> Hi All,
>
> I have searched through the Matlab forums, but haven't found the answer to my question. I would like to use a least squares function to fit some data.
>
> Briefly, I have two equations of the form
>
> Z1 = a + b*x + c*y + d*x*y
> Z2 = e + f*x + g*y + h*x*y
>
> where i know Z1, Z2, x, and y and they're in vector form. I have a few hundred data points, so the lack of data is not an issue. Is there a way I can use the lsqcurvefit function to figure out a thru h or is this a more complex problem?
- - - - - - - - -
It depends on what your criterion for fitting is. You say you know the values for Z1, Z2, x, and y for a number of points and you used the phrase "least squares".

If you want to simply minimize the mean squares of the differences in the left and right hand sides of these equations, then you have an ordinary problem in linear least squares in determining the best values of the coefficients, a, b, c, ..., h, since the problem is linear in these coefficients.

On the other hand each of the equations represents a hyperbolic paraboloid surface in x, y, z space for a fixed set of coefficients and perhaps you wish to adjust these coefficients so that the mean square orthogonal distances from your points to the surface are at a minimum. That is a much more difficult problem, since it involves working with roots of sixth degree polynomials.

Just what sort of minimization do you have in mind? At this point it looks as though the two equations represent two entirely independent problems. Is there some connection between them that you haven't told us about, besides the fact that they have x and y values in common?

Roger Stafford