# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Interpolate array

Hello,

I'v got a question to you. I'v got two plots. They have similar x values, but diferent size. For now I created VI that is searching for upcoming value from x1 in x2, then I'm taking that array of indexes, and get right values from y2 array to my desired "interpolated" y2 array. It calculates properly, but works very slow, and when I'm trying to do it on 200k elements array it tooks 1,5min to acomplish my task.

Does anybody know how can I do it faster?

Message 1 of 6
(3,060 Views)
Solution
Accepted by topic author wojtek432

## Re: Interpolate array

Hi wojtek,

LabVIEW brings functions for lookup tables:

Is this what you are looking for?

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(3,035 Views)

## Re: Interpolate array

Thank you, this is what I was looking for. But could you tell me, If I can somehow speed it up?

Message 3 of 6
(3,026 Views)

## Re: Interpolate array

Hi wojtek,

If I can somehow speed it up?

You could parallize the FOR loop…

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(3,012 Views)

## Re: Interpolate array

Your code is slow because the arrays are not sorted by x and sorting is expensive for large arrays. Where does the data come from? What precision do you need? How do you measure speed? How often does this need to run?

What data are you interested in? (difference in Y? relative shift in x? etc.) Overall, you seem to have way too much data to describe the curve, so if you could somehow decimate it to a more reasonable size, if will speed up greatly. Adjacent points are currently highly correlated (redundant information!)and the same curves can be described with 5% of the points. Also, for the interpolation, you could use a linear x ramp in the range [0.1...1.2] with a few hundred points and interpolate both curves using it as x.

Message 5 of 6
(2,985 Views)

## Re: Interpolate array

Bonus points awarded for staying in character!

Christian wrote;

"

...Overall, you seem to have way too much data to describe the curve, so if you could somehow decimate it to a more reasonable size, if will speed up greatly.... the same curves can be described with 5% of the points....

LabVIEW Champion Do more with less code and in less time

"

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 6
(2,982 Views)