interp1 vs interp1q R2015a
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
First off I realise interp1q might be deprecated. They have stated that for several versions now.
I've been refactoring some code (on release 2015a) and being aware they improved interp1's performance considerably I thought I would test the speed between the two again.
Test Code:
x = [0;1];
y = [0;1];
xx = rand(1e7,1);
tic;interp1(x,y,xx);toc
tic;interp1q(x,y,xx);toc
The results:
Elapsed time is 0.051931 seconds.
Elapsed time is 1.866386 seconds.
Interp1 is now, well shall we say, massively quicker than interp1q. I haven't delved into the code but interp1q was always quicker because of less error checking etc. It seems clear that interp1q has not been touched while interp1 has moved along.
Any idea of how we can "rewrite" interp1q to make it faster than interp1 taking into account that error checking etc can be handled before entering the function?
PS: In some industries, interpolation is one of the most time consuming calculations, since it gets called millions of times. So even a small increase in speed makes a massive difference in overall run-time.
Regards,
Phil
2 Commenti
John D'Errico
il 1 Apr 2015
1. Never use tic and toc to time code, unless you have no choice. (There are SOME circumstances where tic and toc are reasonable for use.) Use timeit instead. It will always give you better time predicitons.
2. A vector of only 2 points may be a poor test of these functions.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Multidimensional Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!