From: Fran on
Hello everyone,

I would really appreciate all of your help. I've scoured the file exchange, looking for a way of fitting a 2D surface with polynomials. After using two (both of which are great! Links at bottom of post) functions on the file exchange, I discovered that orthogonal polynomials are needed, such as Chebyshev or Legendre.

However, I can't for the life of me find any code which does this already. Has anyone else approached this problem, or can advise me on how to proceed?

Thanks a million,

Fran


http://www.mathworks.com/matlabcentral/fileexchange/10065-polyfitn
http://www.mathworks.com/matlabcentral/fileexchange/13719-2d-weighted-polynomial-fitting-and-evaluation
From: Matt J on
"Fran " <fp04(a)ic.ac.uk> wrote in message <ho0f6o$10l$1(a)fred.mathworks.com>...
> Hello everyone,
>
> I would really appreciate all of your help. I've scoured the file exchange, looking for a way of fitting a 2D surface with polynomials. After using two (both of which are great! Links at bottom of post) functions on the file exchange, I discovered that orthogonal polynomials are needed, such as Chebyshev or Legendre.
>
> However, I can't for the life of me find any code which does this already. Has anyone else approached this problem, or can advise me on how to proceed?
====

Well, as I'm sure you noticed, there are lots of file exchange submissions that do this for 1D, e.g.

http://www.mathworks.com/matlabcentral/fileexchange/20932-legendre-polynomial-fitting

What exactly are your needs in terms of speed? The extension of these tools to 2D is to assume that your 2D orthogonal polynomials are tensor products of 1D polynomials.
So, if the matrix A are the samples of your 2D surface, a simple way to generalize these tools to 2D would be to use a for-loop to do a 1D fit to all the columns of A, followed by the same thing on all the columns.
From: Fran on
Unfortunately I need the fitting to be relatively quick - I will be utilising the code in an optimisation loop with (probably) hundreds of iterations.

I would find it very surprising if this kind of thing wasn't out there, somewhere, already. I think it wold be such a common problem!

Thanks for your help, using a for loop will be the first place I start if nothing else becomes available from this thread! :)

Fran
From: John D'Errico on
"Fran " <fp04(a)ic.ac.uk> wrote in message <ho0f6o$10l$1(a)fred.mathworks.com>...
> Hello everyone,
>
> I would really appreciate all of your help. I've scoured the file exchange, looking for a way of fitting a 2D surface with polynomials. After using two (both of which are great! Links at bottom of post) functions on the file exchange, I discovered that orthogonal polynomials are needed, such as Chebyshev or Legendre.
>
> However, I can't for the life of me find any code which does this already. Has anyone else approached this problem, or can advise me on how to proceed?
>

Why are they "needed"?

If you need to fit such a high order polynomial model
that orthogonal polynomials are necessary, then I'll
contend that you are trying to fit too high an order
model anyway. What will you get out of all of those
dozens of coefficients?

Just use a tool that can fit your surface from data. So
use splines, gridfit (on the FEX, and really a form of
spline model itself), radial basis functions, neural nets,
etc.

http://www.mathworks.com/matlabcentral/fileexchange/8998

http://www.mathworks.com/products/splines/

http://www.mathworks.com/products/neuralnet/

http://www.mathworks.com/products/curvefitting/

John
From: Bruno Luong on
"Fran " <fp04(a)ic.ac.uk> wrote in message <ho0f6o$10l$1(a)fred.mathworks.com>...
> Hello everyone,
>
> I would really appreciate all of your help. I've scoured the file exchange, looking for a way of fitting a 2D surface with polynomials. After using two (both of which are great! Links at bottom of post) functions on the file exchange, I discovered that orthogonal polynomials are needed, such as Chebyshev or Legendre.

It seems to me those are separate issue: fitting and orthogonal functions. Fitting is projection of a function on a (polynomial) subspace; orthogonal polynomials are a requirement on a selected basis of a subspace. You can fit with whatever subspace, and represent this subspace with orthogonal functions or not.

The first problem call for fitting routine, the second requires change of the basis. They are not directly related.

You can start out with *any* basis, and do some sort of Gram-schmidt process to transform into orthogonal basis. Legendre and Chebychev are known as orthogonal because their analytic expression can be conveniently expressed, that's all.

Bruno