LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Point nearest of all in an array

Solved!
Go to solution

Hello

 

I am having two  2 D array of  elements. Array1 and Array2.

I take a value from Array2 and calculate its distance from all the elements in Array1. I need to get the element which is at the shortest distance from it. How is it posible?

 I have made a VI.After calculating the distance how is it possible to check for the shortest and how to store that nearest value in an array??

 please have a look

Thanks 

 

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 1 of 8
(3,911 Views)

Hi Nghtcrwlr,

if i understand it correct, then the "Array Min & Max" function should help.

 

Mike

0 Kudos
Message 2 of 8
(3,906 Views)
Solution
Accepted by topic author Nghtcrwlr

While I did not quite understand what kind of output you want, here's one possible solution that can probably point you in the right direction. Good luck!

 

 

I assume you want the value of the nearest array element and I assume by distance you mean the 2D distance between the two points in the complex plane. Other interpertations would be to get the array indices of the closest value, for example.

Message Edited by altenbach on 03-12-2009 09:19 AM
Download All
Message 3 of 8
(3,891 Views)
It is possible that I have the meaning of array1 and array2 reversed in my code, so please double-check. 😄
0 Kudos
Message 4 of 8
(3,882 Views)
0 Kudos
Message 5 of 8
(3,853 Views)

Hello Everybody!!

 

I had tried the Max n Min function but it alone didnt do anything. With the stuff altenbach mentioned its wrking..thanks.....Its an easy way jus to take the differene and thefind tha absolute value instead of calculating as per the general formula. I am not quite clear with the part after finding the absolute value. Can you please make it a bit clear??/

 

Thanks

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 8
(3,842 Views)

Nghtcrwlr wrote:

I am not quite clear with the part after finding the absolute value. Can you please make it a bit clear??/


After you get the 2D array of distances, we use array min/max to get the value and position of the smallest element.

 

Then we index in the original complex array to get the complex value.

Message Edited by altenbach on 03-12-2009 01:24 PM
0 Kudos
Message 7 of 8
(3,836 Views)

Ok... now everythin is clear. I usually use Max & Min func only to get the maximum & minimum value... i hardly notice the max n min index frm it....

 

Thank you very much!!!Smiley Happy

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 8
(3,820 Views)