LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW MAP ceiling / floor function -- or return nearest neighbors if item not found.

Solved!
Go to solution

I wondered if there was a way to use the new LabVIEW MAP functions to find "near", but not exact, matches.  In other words, if an exact match is not found, is there a way to return the nearest value that is above and below the key being searched for?

 

I'm guessing that exporting the map to an array for each "find" operation would not be efficient.

 

It seems like the answer might be no and that I should consider an using an array of a custom cluster where I write, insert, remove, and find VIs to keep the items in the array sorted and to find the nearest key.

 

Thoughts?

Thanks

Jim

0 Kudos
Message 1 of 3
(1,098 Views)
Solution
Accepted by topic author JimASim

@JimASim wrote:

Thoughts?

Thanks

Jim


The answer is indeed 'no'.

 


@JimASim wrote:

I'm guessing that exporting the map to an array for each "find" operation would not be efficient.


You might be wrong about that.

 

Iterating all elements of a map should be just as fast as looping over all items in an array.

 

Of course if you have an ordered array, that would be faster iff you can take advantage of the ordering. That would take some work though. The new .vims in LV21 would search for exact matches, not nearest.

 

0 Kudos
Message 2 of 3
(1,065 Views)

.Thanks.   I was intending on keeping the array ordered at all times by inserting new items in their appropriate place.  Then I would binary search the array for the item I was looking for.

 

Jim

0 Kudos
Message 3 of 3
(1,036 Views)