LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding most similar values in 2D array

Solved!
Go to solution

Hello,

 

I have a 2D array of floating point values. Each row represents the profile of an object (the width in a given plane). Each object is sampled about 40 times - so 40 values per row, and we will end up with about 150 profiles. In other words it's not exactly a small array.

 

I need to compare these profiles with an incoming profile and return the best match for these values. Note that the floating point values will never match exactly.

I need to perform this comparison about 3 times per second, so I'm looking for a fast yet reliable solution.

 

I have found a couple posts here on the forum, which suggest simply running through each and every value and compare the variance. Though I haven't benchmarked it, I fear it may be resource intensive (and find it rather unelegant as well).

 

I have looked into CrossCorrelation.vi, which seems to be what I'm looking for. The problem there is that I'm not really sure what to make of the output from that function. 

As far as I understand, the higher the values outputted from the Rxy terminal, the higher the deviation between the inputs. If that's correct, I could simply add up the Rxy values for each comparison and pick the one with the lowest value.

 

What I'm looking for is thoughts and ideas in general about my cross correlation solution (would it work at all?), and about any alternative solutions you might know of.

 

Thank you,

-Tobias

 

0 Kudos
Message 1 of 5
(2,784 Views)
Solution
Accepted by topic author Tobias_Jønch

Hi Tobias,

 

to find a "best match" you have to define a criteria for your matches.

 

Usually people use:

- max deviation

- mean deviation

- root mean squares…

 

Once you decide which criteria you want to use you can calculate that value for each profile. Then simply select the profile with best criteria value…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(2,776 Views)

Hi GerdW,

 

Many thanks for your reply.

 

Do you have any idea which of these are most precise and fastest?

 

Do you know if people decide based on aspects other than these two?

 

Thanks for the fast reply, much obliged.

0 Kudos
Message 3 of 5
(2,770 Views)

Hi Tobias,

 

calculating differences is rather fast. Adding or getting the mean of the differences is fast too. A modern CPU should do all this in some µs for arrays of 1000 elements…

 

How fast should that calculation be done?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,764 Views)

Yeah, a bit of testing seems to show I'll have little trouble using the deviation VIs.

 

Thanks a bunch for your help 🙂

0 Kudos
Message 5 of 5
(2,752 Views)