LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A more efficient lookup table for numeric data?

Solved!
Go to solution

Hi All,

 

I've attached a VI that interpolates a data set and then uses the 'Search 1D Array' function to obtain a value for the corresponding value in the interpolated data.

 

When slotting this VI in my overarching code, it seems to become considerably less responsive at smaller time-steps. After looking up online for more efficient methods of implementing look-up tables, it suggested using variant attributes. However, the post I read suggested that this can only be done for string data inputs.

 

Is there a more efficient way of doing this? And if variant attributes would work, could somebody show me how?

 

Any help would be amazing.

 

Thanks,

Chango 

0 Kudos
Message 1 of 7
(3,845 Views)
Solution
Accepted by topic author ChangoMutney

Posting by phone, cannot see your VI.

 

Is the table sorted? If so, threshold array will give you interpolated data directly and efficiently. Or you can do a binary search.

A real LUT does not give you any interpolation or "most similar", so variant attributes are out.

Message 2 of 7
(3,832 Views)

Hi and thanks for your reply.

 

My array is 2 dimensional in the following format:

RPM          Torque

4000           45.0843

4001           45.0918

4002           45.0992

...etc, from 4000 to 15000

 

What I would like to do is be able to pick out an RPM value and the code to output the corresponding Torque value.

 

From my understanding of the threshold array function, doesn't it only work with 1D arrays?

 

Many thanks,

Chango

0 Kudos
Message 3 of 7
(3,804 Views)

Sorry, I may be being a bit dull here. I think i've figured it out.

 

Thanks very much.

0 Kudos
Message 4 of 7
(3,794 Views)

Based on the information so far (fixed range of integer RPM values) I would create a 1D array of the torque values and then simply index that array using index (RPM-4000).  For example RPM=4001 would correspond to index 1 in your LUT.

0 Kudos
Message 5 of 7
(3,791 Views)
Solution
Accepted by topic author ChangoMutney

So you want a spline of the original 12 points for a 1RPM resolution. All you need is get the interpolant once, then use it to get any value in-between with unlimited resolution, even for fractional torque values. No need to store the interpolated array at 1rpm resolution, that's just a waste of memory (Your data structures: 264216 bytes, mine 288 bytes, or 917x less!!!). Here's what I had in mind:

 

Spliner.png

 

 

Message 6 of 7
(3,783 Views)

Thank you very much! That's a really neat piece of code!

Always looking to improve my code! 

0 Kudos
Message 7 of 7
(3,727 Views)