octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #65134] griddata function incompatibility with


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #65134] griddata function incompatibility with MATLAB
Date: Mon, 8 Jan 2024 12:47:49 -0500 (EST)

Update of bug#65134 (group octave):

                  Status:                    None => Confirmed              
        Operating System:                  Mac OS => Any                    

    _______________________________________________________

Follow-up Comment #2:

It's documented.  But badly.  I haven't dug into archived documentation to see
if they've just been bad about keeping changes consistent.

Most clearly, if you 'help griddata' in 2023b you get this piece:


Vq = griddata(X,Y,V,xq,yq) where xq is a row vector and yq is a column
    vector, expands (xq,yq) via [Xq,Yq] = meshgrid(xq,yq).
    [Xq,Yq,Vq] = griddata(X,Y,V,xq,yq) also returns the expanded grid
    coordinate arrays (Xq,Yq) obtained from meshgrid.


On the griddata doc webpage, as of version 2023b the Input Arguments section
tells you: 


xq, yq, zq — Query points
vector | array
Query points, specified as vectors or arrays. Corresponding elements in the
vectors or arrays specify the xyz coordinates of the query points. The query
points are the locations where griddata performs interpolation.

Specify arrays if you want to pass a grid of query points. Use ndgrid or
meshgrid to construct the arrays.

Specify vectors if you want to pass a collection of scattered points.


but then you got down to Output Arguments section, and you get:


Xq, Yq — Grid coordinates for query points
vectors | matrices
Grid coordinates for query points, returned as vectors or matrices. The shape
of Xq and Yq depends on how you specify xq and yq:

If you specify xq as a row vector and yq as a column vector, then griddata
uses those grid vectors to form a full grid with [Xq,Yq] = meshgrid(xq,yq). In
this case, the Xq and Yq outputs are returned as matrices that contain the
full grid coordinates for the query points.

If xq and yq are both row vectors or both column vectors, then Xq = xq and Yq
= yq.


They could use a little reconciliation between the text in the input and
output sections. but based on the help text and the behavior matching the
output, it seems to be fairly clear that it's intentional. 

Also, worth noting that apparently the actually undocumented part is that it
will do the meshgrid expansion no matter which is a row or column vector, as
long as they aren't both the same. See below. I haven't checked what it does
for the (...,xq,yq,zq,...) input form.


>> vect = [0 5 10]
vect =
     0     5    10
>> [Xi,Yi,Zi] = griddata(0:10,0:10,rand(11,11),vect,vect)
Xi =
     0     5    10
Yi =
     0     5    10
Zi =
    0.2467    0.4646    0.1641
>> [Xi,Yi,Zi] = griddata(0:10,0:10,rand(11,11),vect',vect')
Xi =
     0
     5
    10
Yi =
     0
     5
    10
Zi =
    0.5891
    0.0718
    0.5979
>> [Xi,Yi,Zi] = griddata(0:10,0:10,rand(11,11),vect',vect)
Xi =
     0     5    10
     0     5    10
     0     5    10
Yi =
     0     0     0
     5     5     5
    10    10    10
Zi =
    0.6545    0.6280    0.0616
    0.0396    0.5895    0.4681
    0.3776    0.9814    0.8341
>> [Xi,Yi,Zi] = griddata(0:10,0:10,rand(11,11),vect,vect')
Xi =
     0     5    10
     0     5    10
     0     5    10
Yi =
     0     0     0
     5     5     5
    10    10    10
Zi =
    0.0023    0.5574    0.9063
    0.0300    0.3525    0.0010
    0.9422    0.2688    0.7024




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65134>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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