From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interpolate array

Solved!
Go to solution

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?

0 Kudos
Message 1 of 6
(3,367 Views)
Solution
Accepted by topic author wojtek432

Hi wojtek,

 

LabVIEW brings functions for lookup tables:

check.png

Is this what you are looking for?

Best regards,
GerdW


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

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

0 Kudos
Message 3 of 6
(3,333 Views)

Hi wojtek,

 

If I can somehow speed it up?

You could parallize the FOR loop…

What is your requirement?

Best regards,
GerdW


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

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
(3,292 Views)

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