LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i count the number of data patches in a numeric array

Hi All
0 Kudos
Message 1 of 9
(4,972 Views)

Hi

 

I have a numeric array with positive and negative numbers. I want to count the patches of negative numbers in an array. I can count the total elements of negative numbers through an index count but when the gentive numers are shown in groups one after the other i want to count how many of this groups/patches i have on my array.

 

i would thank you in advance for replying back

 

bobLondn

0 Kudos
Message 2 of 9
(4,969 Views)

Put the current element into a shift register.  Increase the count (also in a shift register) if the current element of the data array is negative AND the previous element was positive.  This way the count only increases when the transition from positive to negative occurs.  You will need to consider the behavior you want for the first and last elements of the array and how to handle elements which may be zero.

 

Lynn

 

Count Patches.png

0 Kudos
Message 3 of 9
(4,947 Views)

Hi

 

Thank you for your help. It worked perfectly.

 

Is there any chance you can give me a  little hint in how to find the first index of a data patch and the length of elements on that data patch

 

Regards

 

London

0 Kudos
Message 4 of 9
(4,939 Views)

Hi, this does thing does the index finding thing you were asking about.

LabVIEW 8.2,8.6,2009...still learning 😛
0 Kudos
Message 5 of 9
(4,913 Views)

Check the attached example.

 

-Kumar.B

0 Kudos
Message 6 of 9
(4,902 Views)
Hi
0 Kudos
Message 7 of 9
(4,878 Views)

 

Hi 
 

I really appreciate your response, amazingly quick.

 

I just wanted to make this a little complicated however; well for me at list.

  

Can I build a 2d array where I can store on one column the index of each data patch and on the second column to store the length of elements of relevant data patch.

 

Once again thank you for your support,

  

Regards

 

London

 

0 Kudos
Message 8 of 9
(4,873 Views)

 


@BobLondn wrote:

 

Can I build a 2d array where I can store on one column the index of each data patch and on the second column to store the length of elements of relevant data patch.


 

Here's a quick example (LabVIEW 9.0) that stores the start index and length of all negative patches in a 2D array.

 

 

(modified from this old code)

0 Kudos
Message 9 of 9
(4,855 Views)