help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FIXED (again): INTERP2 problem


From: Paul Kienzle
Subject: Re: FIXED (again): INTERP2 problem
Date: Sun, 27 Nov 2005 13:35:11 -0500


On Nov 27, 2005, at 8:49 AM, Pierre Baldensperger wrote:

Paul Kienzle wrote:

I'm happy to support XI and YI arbitrary, however according to the docs on the web, interp2(z,[1:5],[1:6]) should return a 5x6 matrix. Do you have
reason to believe otherwise?


Well, yes, sorry... Which web docs are you referring to?
Matlab behaves differently depending whether YI is a row or column vector:

- interp2(Z,[1:5],[1:6]) should not work
- interp2(Z,[1:5],[1:6]') should indeed auto-grid and return a 5x6 matrix

Ick.  I've posted a change which does this.

I missed the significance of "...you can pass in the row and column
vectors xi and yi..." meaning that one had to be a row and the other
a column.

BTW, the docs mention that interp2 can accept an extrapolation value
as the last parameter rather than always using NaN.  You may wish
to implement this feature for your problem.

I have no Matlab handy to check that, but that is how I understood the
Matlab help for interp2, and that is also IMO the way it should ultimately
behave. Why would we forbid anybody to perform a 2D-to-1D interpolation
with that function (that is: entering a 1D-list of XI and YI and returning
a 1D vector ZI)?

Agreed.  That way you can take a slice through a surface.

In the present case, I'm concerned with limiting the field of application of that routine, just because we want to avoid "lazy" users a (_trivial_)
preliminary call to meshgrid.

So if you really want to restore this "auto-meshgridding" behaviour, I'd suggest you trigger it the "Matlab way" (or at least the way I understand
it ;-), that is:

- if XI and YI have the same size and orientation, do _not_ meshgrid
- if XI and YI have the same orientation but different sizes, _error_
- if XI and YI have different orientations, auto-meshgrid

Of course, that may cause programs relying on the "auto-meshgridding" to
fail when they provide XI and YI with the same orientation (even with a
"silent" failure when they have the same size).

Personally, I always feel uncomfortable with routines that "think" for
the user (same for programs, e.g. MSWord...), so I would entirely remove
that "auto-meshgridding" thing.

Yeah, treating x and x.' identically in routines that accept
vectors probably seemed like a good idea at the time, but it
does lead to a lot of ugliness.  We are stuck with it.

Does it provide any performance or memory gain?

It could but we don't have the code in place to take
advantage of it.  If anyone were using interp2 to rescale
lots of images they might want to improve it.

Here's a test for non-gridded XI and YI based on my initial 2D polar to
rectangular interpolation example (simplify if necessary):

Okay, I simplified.

Thank you for your help and explanations,
-Pierre.

Thank you for your contributions,

        - Paul



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]