Thread Subject: griddata: can we get equation of surface?

Subject: griddata: can we get equation of surface?

From: murthy m

Date: 4 Feb, 2008 10:17:03

Message: 1 of 4

Hi
  I am using Matlab function 'griddata' to form a surface,
is it possible to know the equation of this surface?
or is it possible to fit a predefined surface equation of
the form z=f(x,y) for the 3D data by any other method?

Thanks in advance

Subject: griddata: can we get equation of surface?

From: John D'Errico

Date: 4 Feb, 2008 11:06:03

Message: 2 of 4

"murthy m" <mmurthy007@googlemail.com> wrote in message
<fo6omv$ruq$1@fred.mathworks.com>...
> Hi
> I am using Matlab function 'griddata' to form a surface,
> is it possible to know the equation of this surface?

No. There is no single "equation". Depending
on the method chosen for the interpolation,
griddata uses a variety of local models to
interpolate with. But none of them provide
any simple equation that you can use.

Just like the spline interpolants found in
interp1, interp2, and interpn, the result is
built up in general from tiny little pieces of
functions. The same can be said for my own
gridfit, in case you hope for something there
along these lines.


> or is it possible to fit a predefined surface equation of
> the form z=f(x,y) for the 3D data by any other method?

Yes, you can do this, with a big caveat.

You need to choose your own model, in
advance. Just as in any linear or nonlinear
regression in 1-d, you need to choose a
logical model for your fit.

One simple alternative is the family of
polynomial models. Because they are so
simple to use and fit, many people use
them. In fact, you can find my own code,
polyfitn, on the file exchange. It can fit a
polynomial model for data in 1, 2, or a
higher number of dimensions. You still
need to choose the terms in the model
though.

Sadly, polynomial models can have some
serious flaws, despite the fact that Taylor
series have been around for a gazillion
years. In fact, I'd rarely recommend
polynomial models. Its almost that they
are too easy to use. The user tends to
use higher order models, thinking that a
lower residual error means a better fit.

Radial basis function models, thin plate
splines, etc., are other options. But they
too don't provide any simple models to
write down. No panacea there either.

In the end, you are best served if you
really need a simple equationl that you
can write down, by knowing your data.
Know where it comes from, know what
it means. Derive a model for that data
from physical principles. Then use a tool
to estimate the parameters of that model.
Unfortunately, this can take some effort.
But nothing worth doing is worth doing
poorly.

Since I can talk about this subject for
hours, I'll stop here.

John

Subject: griddata: can we get equation of surface?

From: murthy m

Date: 4 Feb, 2008 11:53:02

Message: 3 of 4

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fo6rir$254$1@fred.mathworks.com>...

Thank you. Your 'gridfit' function is excellent. In my case,
just to give you an idea of what I am trying, I have x,y and
z matrices as given below and I want to choose an
exponential function of the form
Z(x,y)=exp[-(x-x(i))-(y-y(i))/m*m] where m is a constant to
be obtained. Is it possible?

>> x=1:7;
>> y=1:11;
>> z=
[0.3100 0.3393 0.3638 0.4013 0.3783 0.3485
 0.3258
    0.3450 0.3996 0.4548 0.5188 0.4564 0.4052
   0.3471
    0.3704 0.4487 0.5299 0.6182 0.5357 0.4555
   0.3769
    0.3997 0.5052 0.6176 0.7382 0.6186 0.5185
   0.4039
    0.4279 0.5614 0.7074 0.8544 0.7155 0.5784
   0.4389
    0.4602 0.6335 0.8104 1.0000 0.8238 0.6521
   0.4743
    0.4372 0.5812 0.7335 0.8823 0.7279 0.5845
   0.4327
    0.4001 0.5199 0.6393 0.7660 0.6502 0.5318
   0.4108
    0.3769 0.4704 0.5695 0.6650 0.5740 0.4791
   0.3816
    0.3460 0.4139 0.4785 0.5481 0.4886 0.4199
   0.3559
    0.3197 0.3578 0.3943 0.4302 0.3958 0.3579
   0.3212];


Subject: griddata: can we get equation of surface?

From: John D'Errico

Date: 4 Feb, 2008 13:06:04

Message: 4 of 4

"murthy m" <mmurthy007@googlemail.com> wrote in message
<fo6uau$47e$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <fo6rir$254$1@fred.mathworks.com>...
>
> Thank you. Your 'gridfit' function is excellent. In my case,
> just to give you an idea of what I am trying, I have x,y and
> z matrices as given below and I want to choose an
> exponential function of the form
> Z(x,y)=exp[-(x-x(i))-(y-y(i))/m*m] where m is a constant to
> be obtained. Is it possible?
>
> >> x=1:7;
> >> y=1:11;
> >> z=
> [0.3100 0.3393 0.3638 0.4013 0.3783 0.3485
> 0.3258
> 0.3450 0.3996 0.4548 0.5188 0.4564 0.4052
> 0.3471
> 0.3704 0.4487 0.5299 0.6182 0.5357 0.4555
> 0.3769
> 0.3997 0.5052 0.6176 0.7382 0.6186 0.5185
> 0.4039
> 0.4279 0.5614 0.7074 0.8544 0.7155 0.5784
> 0.4389
> 0.4602 0.6335 0.8104 1.0000 0.8238 0.6521
> 0.4743
> 0.4372 0.5812 0.7335 0.8823 0.7279 0.5845
> 0.4327
> 0.4001 0.5199 0.6393 0.7660 0.6502 0.5318
> 0.4108
> 0.3769 0.4704 0.5695 0.6650 0.5740 0.4791
> 0.3816
> 0.3460 0.4139 0.4785 0.5481 0.4886 0.4199
> 0.3559
> 0.3197 0.3578 0.3943 0.4302 0.3958 0.3579
> 0.3212];

In theory, one could estimate the coefficients of
your model from data such as this. There are
several methods one might use, ranging from a
nonlinear regression to a transformation to a linear
regression problem. HOWEVER...
 
Do you realize that your model does not even come
REMOTELY close to having the correct shape for
this surface? Have you properly written down the
actual model that you will use?

John


Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com