From: Nicolas Guillemette on

I'm looking for a function that finds the coefficients of a
polynomial of degree n that fits the data of a three
dimensional set of variables. I have X, Y and Z vectors and
I want to fit a plan (not a curve)on XY plan ?

How can I proceed ?


Thx

Nicolas Guillemette
From: Bruno Luong on
"Nicolas Guillemette" <nico_guillemette(a)hotmail.com> wrote
in message <fvl1q3$8sv$1(a)fred.mathworks.com>...
>
> I'm looking for a function that finds the coefficients of a
> polynomial of degree n that fits the data of a three
> dimensional set of variables. I have X, Y and Z vectors and
> I want to fit a plan (not a curve)on XY plan ?
>
> How can I proceed ?
>

[X(:) Y(:) ones(numel(z),1)] \ Z(:)

provides you (a,b,c) of the fitted plane z=ax+by+c

Bruno

From: Bruno Luong on
Sorry for the typo (uppercase z)
>
>
> [X(:) Y(:) ones(numel(Z),1)] \ Z(:)
>
>