LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

iteration through a 2D array and break out of the loop when condition is met

 

Hi,

 

I will be thankful if somebody could help me to write a program which would step through the rows of a 2D array and at a first element in the row smaller than a given number it will increment the counter and jump to the next row. After having gone through whole array, the counter will indicate the number of the rows meeting the verification condition.

 

Mike

0 Kudos
Message 1 of 6
(4,300 Views)

You can use nested for loops with a shift register. If you right click on the inner one, select 'Conditional Terminal'. Just like a while loop,you can terminate it this way and still make use of the autoindexing. The outer for loop indexes by rows and the inner will index by element.

0 Kudos
Message 2 of 6
(4,281 Views)

Find attached 'Conditional Counter' (VI snippet).

 

Example Code - Conditional Counter

 

Edited: Its worth knowing the concept of 'Auto Indexing'


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 3 of 6
(4,276 Views)

That does not work since it only looks at element 0 in each row. As I understand the requirement, it should look at all elements in a row but only count a row once if multiple conditions exist.

0 Kudos
Message 4 of 6
(4,273 Views)

Ohhh I considered checking only the first (zero indexed) element to be checked and then move on to the next row.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 5 of 6
(4,267 Views)

I prefer doing these things with a comparrison and an Or Array Elements

 

0 Kudos
Message 6 of 6
(4,244 Views)