11-07-2010 12:21 PM
11-07-2010 12:24 PM
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
11-07-2010 06:00 PM
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
11-07-2010 07:06 PM
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
11-08-2010 03:23 AM
Hi, this does thing does the index finding thing you were asking about.
11-08-2010 05:09 AM
Check the attached example.
-Kumar.B
11-08-2010 01:30 PM
11-08-2010 01:35 PM
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
11-08-2010 06:37 PM - edited 11-08-2010 06:41 PM
@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)