Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Error using interp1 function

$
0
0
On Saturday, June 29, 2013 8:25:07 AM UTC+12, rohith Eggidi wrote:
> "Matt" wrote in message <k9nohk$c9f$1@newscl01ah.mathworks.com>...
>
> > Hello everybody.
>
> >
>
> > After using the following function :
>
> >
>
> > --------------
>
> > AAA=interp1(d, time3, 20, 'linear','extrap')
>
> > --------------
>
> >
>
> > I'm getting the following error :
>
> >
>
> > --------------
>
> > Error using griddedInterpolant
>
> > The point coordinates are not sequenced in strict monotonic order.
>
> > --------------
>
> >
>
> > Does anybody knows why ? d and time3 are both 1x330 double elements and basically I'm trying to
>
> >
>
> > I can provide more details is needed.
>
> >
>
> > Thanks a lot ! :-)
>
>
>
> Since you said both d and time are increasing and the error say non monotonic, i think the problem is that the d is non decreasing i.e it could flatten for periods of time. this is probably why the interp1 function is throwing an error as it is picking up multiple times when d is at 20. I am currently facing a similar problem building empirical marginal distributions for a large data set and am looking for a solution. Please post if any insight on either issues.

This problem often arises when you have built a cumulative distribution function (CDF) from a histogram using cumsum, then try to interpolate. If one of the bins in the histogram is zero, then the CDF will have double probabilities for a particular value. The problem is easily fixed using unique:
[P1,indx]=unique(P);
v1=v(indx);

Viewing all articles
Browse latest Browse all 19628

Trending Articles