05-13-2019 11:41 AM
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
Solved! Go to Solution.
05-13-2019 12:39 PM
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.
05-13-2019 02:09 PM
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
05-13-2019 02:15 PM
Sorry, I may be being a bit dull here. I think i've figured it out.
Thanks very much.
05-13-2019 02:17 PM
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.
05-13-2019 02:49 PM - edited 05-13-2019 03:17 PM
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:
05-14-2019 06:17 AM
Thank you very much! That's a really neat piece of code!
Always looking to improve my code!