From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search Indices in 2D Array in a Range

Solved!
Go to solution

Hello.

 

I have two 2D Arrays (9x9) and I would like to find indices of an element that lies in a specific range. For example, ±15% of the value I look for. I have found and implemented Search 2D Array.vi, it works well but it is possible to set only one number to search for, not a range. So, I am stuck at this stage.

 

Any help is highly appreciated!

 

Thanks.

 

2D Array Image.jpg

 

Download All
0 Kudos
Message 1 of 16
(3,945 Views)

I am not really clear about your question. Do you mean, if you have a value (lets say 100) so you want to find the numbers between 85 to 115? Also your Search 2D array VI is missing in your attachement.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 16
(3,942 Views)

Hi Ivan,

 

your VI uses some missing subVIs from your addon folder…

 

To give you a start:

check.png

All you need to do now is to look for TRUE values in the 2D boolean "in range?" array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 16
(3,940 Views)

Oh, sorry. Here is the VI.

 

Yes, you are absolutely right. If the value is 100, then I would like to find numbers in the range 85 - 115. Here 15% is like a permissible error. 

 

 

 

0 Kudos
Message 4 of 16
(3,934 Views)

Thanks for your reply.

 

How can I get indices in this case? 

0 Kudos
Message 5 of 16
(3,930 Views)

Hi Ivan,

 

use FOR loops to iterate over the 2D boolean array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 16
(3,927 Views)

Here is an implementation of GerdW's concept.  Note that it does not distinguish between valid zero value indexes and the default in the array.  You will need to decide how to manage that situation.

 

Lynn

 

Message 7 of 16
(3,917 Views)

Thank you! I`ll try this method. 

0 Kudos
Message 8 of 16
(3,912 Views)

Lynn,

I am confused a bit. Please look at the attached image. Range is 0,54-0,66. I think that the first value in Indexes array is number of row and the second is number of column, am I right? If so, (0,0) corresponds to 0.678852, (0,2) is 0.209174 which is out of the range. But (1,0) is 0.574114 which lies within the limits. However, somehow 0.56365 and 0.652643 (circled in green) have not been detected...


Another question is what does it mean when only one column in Indexes array is active?

 

Also this VI cannot cope with negative values due to terminals mismatch in in Range and Coerce.vi. So probably I need to make two of them for both positive and negative values.

 

Actually every element in the arrays from VI I attached previously corresponds to a specific point in a plane (a metal sheet). It means that if two pairs of indices are equal then the specific point is found. So, I need only one pair of indices, otherwise mismatch occurs.

 

Thanks for your help!

 

question.jpg

0 Kudos
Message 9 of 16
(3,898 Views)

Hi Ivan,

 

for me it works:

check.png

Using simple math (ABS function) isn't your strength, isn't it? 😄

And combining the results neither…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 16
(3,882 Views)