Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: BUG in histc !!?
Replies: 5   Last Post: Sep 16, 2013 2:05 PM

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: BUG in histc !!?
Posted: Sep 16, 2013 2:05 PM

"R " <yaelds@yahoo.com> wrote in message
news:l17b9a\$col\$1@newscl01ah.mathworks.com...
> Hi Penny,
>
> Thank you for your answer. It was my mistake to not see the date of the
> email, indeed an old thread. However, I did encounter a recent situation
> (last few months) where I was unable to update to a more recent version of
> Matlab (because the Apple computer could not in turn update to a newer
> OS). The result is that I am now stuck with a Matlab version that cannot
> run TriScatteredInterp on my data because of a bug -- something about not
> being able to handle NaNs. I did contact customer support and they
> mentioned there was no fix for this other than upgrading my Matlab version
> which I can't. (Well they did suggest using zeros or some other
> place-holder but interpolating a zero value is not the same as ignoring a
> NaN value. I could use a ridiculously high value so I can reject high
> values in the interpolated field, but I would be loosing data that way. I
> would rather interpolate from the good values while ignoring the NaN
> ones.)

*snip*

handling NaN values in the data (not coordinates) used by
TriScatteredInterp. You said that you would "rather interpolate from the
good values while ignoring the NaN ones." If the NaNs are in the data inputs
to TriScatteredInterp and not the coordinate inputs, an easy way to do that

x = rand(100,1)*4-2;
y = rand(100,1)*4-2;
z = x.*exp(-x.^2-y.^2);

% Introduce a NaN
zz = z; zz(1) = NaN;

finiteonly = isfinite(zz);

% Use just the "good" data
F = TriScatteredInterp(x(finiteonly), y(finiteonly), zz(finiteonly));

% Check and see how it did
differenceShouldBeSmall = F(x(1), y(1)) - z(1)

*snip*

--
Steve Lord
slord@mathworks.com