help-octave
[Top][All Lists]
Advanced

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

Can't get griddata3 to work


From: mph2
Subject: Can't get griddata3 to work
Date: Mon, 14 Mar 2011 18:32:08 -0700 (PDT)

I can't get griddata3 to work with nicely ordered input data.

I have a set of data, which are temperatures on a x,y,z volume grid.
Unfortunately, some x,y,z triplets are missing in the set, and I was trying
to use griddata3 to get these values by interpolation. My problem is that
apparently the ordering of the original set is relevant to whether griddata3
works. (I can't use interp3 because I don't have temperature data for all
x,y,z triplets.)

I've been trying to use test sample data to see what's going on. If I run a
slightly modified version of the examples:

x = 2 * rand(1000, 1) - 1;
y = 2 * rand(1000, 1) - 1;
z = 2 * rand(1000, 1) - 1;
% x = sort(x);
% y = sort(y);
% z = sort(z);
v = x + y + z;

[xi, yi, zi] = meshgrid(-0.8:0.2:0.8);
vi = griddata3(x, y, z, v, xi, yi, zi, 'linear');
vv = vi - xi - yi - zi;
sum(isfinite(vi(:)))
sum(isnan(vi(:)))

then all is well, and only one or two values in vi end up being NaN. I get
something like 727 values, 2 NaN's or so, depending on the run. But if I
sort the vectors by uncommenting the three lines above, the routing no
longer works. I get one real value, and 728 NaN's or so. The output vi is
useless.
Also, even without sorting, if the x,y,z vectors are only 100 values long,
even without sorting, I get 50% NaN's in the output array vi. Shouldn't 100
values be enough to interpolate?

This all seems very weird. What's going on? Is this fixable?

--
View this message in context: 
http://octave.1599824.n4.nabble.com/Can-t-get-griddata3-to-work-tp3355554p3355554.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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