LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does Interpolate 1D.vi run so slowly?

Problem: I have a curve with 200k points (x,y) acquired by a DA card with an acquisition speed at 200k/s. The curve is nonlinear, and X is not monotonic. Now I'd like to get values of Y corresponding to another array X' with 10k points by Interpolate 1D.vi. The problem is that it will take around 10s to finish this Interpolation calculation. I wonder if there are anyways to speed up the Interpolation process, say finishe it within 1s. Any comments/suggestions are really appreciated. Thanks

Message Edited by Alex Wu on 07-07-2007 04:51 PM

Message Edited by Alex Wu on 07-07-2007 04:51 PM

0 Kudos
Message 1 of 6
(3,410 Views)
Might be a good idea to see your code. I gen'd up something and worse case timing is ~15ms to do the interpolation using a 10,000 element X array and a 200,000 element Y array.
0 Kudos
Message 2 of 6
(3,390 Views)

We definitely need more information:

If X is not monotonic, I can't really see how interpolation should work because you can easily get more than one y value for any given x. Would it be valid to sort your data pairs by x first?

Can you attach a simplified version of your code, preferentially containing some typical data in the controls?

How do you measure the speed?

0 Kudos
Message 3 of 6
(3,386 Views)
There is an Interpolate 1D VI in the Mathematics Interpolation & Extrapolation package that uses a table lookup method instead of the linear method. Here's a description:
"Performs one-dimensional interpolation using a selectable table-lookup method. This VI accepts tabulated dependent and independent variable values Y and X and provides interpolated values yi corresponding to each xi location. This VI finds each value of xi in X and uses the relative location in X to find the interpolated value yi at the same relative location in Y. X is monotonic specifies whether you know, a priori, that the values in X are monotonically increasing with the index. If X is monotonic is TRUE, the interpolation algorithm can avoid sorting X and reordering Y accordingly."

I replaced the linear VI with this one and there is a large decrease in performance (~250 times slower than the linear method). I'll bet this is what Alex is using.

Still want to see the code.
0 Kudos
Message 4 of 6
(3,378 Views)
Yes, Bill, you are right, I use the vi you mentioned in my code. (The code is very simple, just use that Vi) How do you do it to finish the interpolation within 15 ms? Can you show me your code? Thanks
0 Kudos
Message 5 of 6
(3,375 Views)
The 15ms figure came from using the linear method which won't work for you. I suspect the performance of the VI you're using is data dependent. Does your project allow you to just store the raw data and post-process it after data acquisition is over?
0 Kudos
Message 6 of 6
(3,368 Views)