Thread Subject: does anyone know a "faster" interp1?

Subject: does anyone know a "faster" interp1?

From: Roberto Castro

Date: 2 Jul, 2008 20:23:02

Message: 1 of 5

Hi everyone,

I have a code in which I heavily use interp1 (with the pchip
option, btw). Does anyone know of a faster interp1? In the
File Exchange, I only found codes for linear or nearest
neighbor interpolation...

Thanks!!

PS: I really need to interpolate several times. So, I cannot
use pchip to get the polynomial and just evaluate it later on.

Subject: does anyone know a

From: Thomas Clark

Date: 2 Jul, 2008 22:31:02

Message: 2 of 5

If your input vector is evenly spaced, use interp1q.

Alternatively, check the file exchange. 10 seconds of search
gives rise to the following:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10286


(reconstruct the link if it gets broken)

Tom Clark

Subject: does anyone know a

From: Thomas Clark

Date: 2 Jul, 2008 22:48:02

Message: 3 of 5

OK,

Sorry for being a fool... I'm scanning the newsgroup and
didn't notice the implications of your pchip requirement.
The above link won't be right for you.

If your input vector is evenly spaced, interp1q is still a
good bet.

Also, check whether there is any difference between the
following...

x = blah;
y = blah;
xi = blah_interp_points;

yi = pchip(x,y,xi)
% or
yi = interp1(x,y,xi,'pchip')

My understanding is that they're functionally the same, but
interp1 checks the inputs - so it may take longer to run.

Alternatively, try to think outside the box. I once had code
which unavoidably made a lot of 1D interpolations... I
re-jigged the code so that it did all the necessary
interpolations first, to a fine degree. I saved the lot to a
mat file. Then, whenever I re-ran my code, I just loaded the
mat file, and use linear interpolation on the finely spaced
data.

Keep the faith... there's always another way!

Subject: does anyone know a

From: John D'Errico

Date: 2 Jul, 2008 22:53:02

Message: 4 of 5

"Thomas Clark" <t.clarkremove_spam@cantab.net> wrote in message
<g4gvj6$flc$1@fred.mathworks.com>...
> If your input vector is evenly spaced, use interp1q.
>
> Alternatively, check the file exchange. 10 seconds of search
> gives rise to the following:
>
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=10286
>
>
> (reconstruct the link if it gets broken)
>
> Tom Clark

But neither of these options offers a pchip
interpolation.

I don't know of any faster methods, although
is your data equally spaced? If so then a
pchip variant could be made more efficient
for that special case.

John

Subject: does anyone know a

From: Roberto Castro

Date: 3 Jul, 2008 05:12:01

Message: 5 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g4h0se$qso$1@fred.mathworks.com>...
> "Thomas Clark" <t.clarkremove_spam@cantab.net> wrote in
message
> <g4gvj6$flc$1@fred.mathworks.com>...
> > If your input vector is evenly spaced, use interp1q.
> >
> > Alternatively, check the file exchange. 10 seconds of search
> > gives rise to the following:
> >
> >
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
> objectId=10286
> >
> >
> > (reconstruct the link if it gets broken)
> >
> > Tom Clark
>
> But neither of these options offers a pchip
> interpolation.
>
> I don't know of any faster methods, although
> is your data equally spaced? If so then a
> pchip variant could be made more efficient
> for that special case.
>
> John

I'm afraid the data is not equally spaced...

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com