ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array with increment

question is:

Have a while loop iterate over elements in “Loop 2 In” and check if the element is equal to 0 if it is end the loop and output the element #(loop iteration) where the first 0 occurs. I.E. input [44,2,0,12] should output 2 because the 0 element is 44, the 1st element is 2 and the 2nd element is 0. If there is no 0’s in your loop it will take the first blank element as a zero and claim that to be the first 0 in the array.

 

and all i really have is,

Screen Shot 2017-10-22 at 4.22.13 PM.pngPlease help what to do..I am stuck on this question for awhile!!

0 Kudos
Message 1 of 7
(4,791 Views)

You could use Search 1-D array for the zero value.

Message 2 of 7
(4,782 Views)

In the real world, we would just use Search 1D Array.  In situations where I am looking for a specific value in an array of clusters (looking for the element with a certain value in the cluster), then I have used a FOR loop with the Loop Terminator turned on.  Just autoindex on the array and do the comparison inside of the loop.  If your comparison is TRUE, the loop stops.  I also tend to output the cluster (tunnel set to Last Value) so then I have the needed value.  In your case, you use the i terminal instead.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 7
(4,769 Views)

It is the solution.

 

Search zero In Array.jpg

 

Ing. Ovidio Torres (El Salvador).

Message 4 of 7
(4,756 Views)

As its just an a Numeric array without decimal points, Use search 1D Array where you will get the output as First found index and if its not you will get the output as -1

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 7
(4,712 Views)

Yet another homework question...

Kudos are welcome...
Message 6 of 7
(4,694 Views)

As a side note: avoid using comparisons with DBL numbers. You may not get what you expect.

 

0.0000000000000001 does NOT equal 0

0 Kudos
Message 7 of 7
(4,666 Views)