LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

comparison of each array data with a single value

Solved!
Go to solution

Dear Sir,

I am having an array of 500 data and a limit value. Whenever the array value crosses the limit, I want to save the particular array index in an array.

 For example if the values from 30th element to 45th elements are crossing the limits, then I want an output array as 30, 31, 32,......., 45.  When I try to implement this in Labview I couldn’t do it.

I tried using the Greater VI inside the for loop followed by a case .but the output of this is an Boolean value, so if my condition is true it’s sending 1 or its sending 0. So my output array will be will be 1 for 30 to 45 and 0 for the remaining.

But I want the particular iteration number to be in the output. So I tried using case structure and inside the true case I kept the local variable of the iteration but it’s not working since it need some default value for the false case and in output its giving the value of false case also.

 

 

Kindly help me, to solve this problem. Thanks in advance

0 Kudos
Message 1 of 7
(2,955 Views)
Solution
Accepted by topic author Rajeshkumarc

Additionally you need to use shift registers.So In the False Case the array will not be built in shift register .Only in True case the array will be appended.

array index.png

 

0 Kudos
Message 2 of 7
(2,948 Views)

Hi Rajesh,

               Can you post your VI?

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 3 of 7
(2,947 Views)

Try this (LabVIEW 2009). Modify as needed.

 

This is OK for smallish array. For larger arrays, an in-place version would be more appropriate, try it. 😉

0 Kudos
Message 4 of 7
(2,942 Views)

Hi, thanks for your reply. i have atteched the problematic protion alone.

0 Kudos
Message 5 of 7
(2,931 Views)

@Rajeshkumarc wrote:

Hi, thanks for your reply. i have atteched the problematic protion alone.


You have a typical race condition do to indiscriminate overuse of a local variable. There is no way to determine if the indicator "numeric" is written first or if the local variable is read first, but the outcome critically depend on the correct order. LabVIEW is a dataflow language, so the correct way would be to wire from the iteration terminal directly to the upper terminal of the select function, eliminating the local variable.

 

Also, if you are autoindexing on an array, you should NOT wire N. You said that the array has 500 elements. If you wire a 100 to the FOR loop, you will only process the first 100 elements. If you don't wire N, the number of iterations will be determined by the array size automatically.

 

Also, since zero is a valid index, you should probably use someting else for non-matching values, for example "-1". If you don't do this, you will not be able to later determine if the first element was larger or smaller, because both cases would result in a zero. 

0 Kudos
Message 6 of 7
(2,921 Views)

Thanks a lot, its working. .

0 Kudos
Message 7 of 7
(2,907 Views)