Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: 2D nonmonotonic interpolation

Subject: 2D nonmonotonic interpolation

From: nir zag

Date: 17 Jul, 2008 15:56:01

Message: 1 of 5

hi,
i am trying to find a 2D nonmonotonic interpolation.
my data is z(x,y), but again the x and the y are
nonmonotonic data.
I have the same problem when i try to fit 2D curve to this
data.
thank,
n.

Subject: Re: 2D nonmonotonic interpolation

From: Walter Roberson

Date: 18 Jul, 2008 17:21:42

Message: 2 of 5

In article <g5nq2h$kea$1@fred.mathworks.com>,
nir zag <nirzag@technion.ac.il> wrote:

>i am trying to find a 2D nonmonotonic interpolation.
>my data is z(x,y), but again the x and the y are
>nonmonotonic data.

is there a reason you could not use

[sx, sxidx] = sort(x);
[sy, syidx] = sort(y);

sz = z(sxidx, syidx);

Then, presuming that x and y were vectors that formed a grid of (x,y)
pairs, sz would be z reordered onto a monotonic grid whose
coordinates were (sx, sy)

After the sorting, the sx would be monotonic, but possibly not
strictly increasing. If the sorted x are not strictly increasing
and the sorted y are not either, then you have a logistic problem
with interpolation: the standard interpolation routines need one of
the two coordinates to be strictly increasing in order to produce
valid results (otherwise, they have trouble deciding which of the
several y values for each repeated x should be used, and tend to pick
amongst them in non-intuitive ways.)

Subject: Re: 2D nonmonotonic interpolation

From: John D'Errico

Date: 18 Jul, 2008 18:10:21

Message: 3 of 5

"nir zag" <nirzag@technion.ac.il> wrote in message
<g5nq2h$kea$1@fred.mathworks.com>...
> hi,
> i am trying to find a 2D nonmonotonic interpolation.
> my data is z(x,y), but again the x and the y are
> nonmonotonic data.
> I have the same problem when i try to fit 2D curve to this
> data.

Use griddata, or you may find my own gridfit
to be of service.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=8998&objectType=FILE

John


Subject: Re: 2D nonmonotonic interpolation

From: Walter Roberson

Date: 18 Jul, 2008 17:21:42

Message: 4 of 5

In article <g5nq2h$kea$1@fred.mathworks.com>,
nir zag <nirzag@technion.ac.il> wrote:

>i am trying to find a 2D nonmonotonic interpolation.
>my data is z(x,y), but again the x and the y are
>nonmonotonic data.

is there a reason you could not use

[sx, sxidx] = sort(x);
[sy, syidx] = sort(y);

sz = z(sxidx, syidx);

Then, presuming that x and y were vectors that formed a grid of (x,y)
pairs, sz would be z reordered onto a monotonic grid whose
coordinates were (sx, sy)

After the sorting, the sx would be monotonic, but possibly not
strictly increasing. If the sorted x are not strictly increasing
and the sorted y are not either, then you have a logistic problem
with interpolation: the standard interpolation routines need one of
the two coordinates to be strictly increasing in order to produce
valid results (otherwise, they have trouble deciding which of the
several y values for each repeated x should be used, and tend to pick
amongst them in non-intuitive ways.)

Subject: Re: 2D nonmonotonic interpolation

From: John D'Errico

Date: 18 Jul, 2008 18:10:21

Message: 5 of 5

"nir zag" <nirzag@technion.ac.il> wrote in message
<g5nq2h$kea$1@fred.mathworks.com>...
> hi,
> i am trying to find a 2D nonmonotonic interpolation.
> my data is z(x,y), but again the x and the y are
> nonmonotonic data.
> I have the same problem when i try to fit 2D curve to this
> data.

Use griddata, or you may find my own gridfit
to be of service.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=8998&objectType=FILE

John


Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
2d nonmonotonic interpolation nir zag 17 Jul, 2008 12:00:25
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
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 Disclaimer prior to use.
Related Topics