11-14-2011 07:13 AM
Hi,
I got an array with booleans, something like this
[TTFFFFFFFFFFFFTTFFTTT]
and I need to find the longest window were the array elements is equal, in the example above I want to find index 2 and length 12 for the longest window of F and index 18, length 3 for T. Anyone have an idé how I can do this?
Solved! Go to Solution.
11-14-2011 07:33 AM
Hello Tudor,
There is so far I know no ready function in labview to do what you want. However this does not seem really hard to do.
You can link your table to a for loop and compare at each iteration the current boolean value to the previous one. If both are true, for example, you can increment a counter until one is true and the other false. Then you can save the length in a separate shift register if this length is longer than the preexisting one (initialize with 0).
About the index, you can save the count terminal of the foor loop in a shift register when the value N-1 of your array is different than the value N, At the next difference, if the length is the longer one, you save this count minus one in another register.
I hipe this helps you.
Regards
11-14-2011 10:32 AM
This is maybe a bit clunky, but it gets the job done.
11-14-2011 10:37 AM - edited 11-14-2011 10:38 AM
I was more seing something with Case Structures but that was basically what I ment. I'm glad it is working for you.
Regards
11-14-2011 11:25 AM
I try to avoid case structures because they hide half the code from you at any given time. I prefer to be able to see the whole VI at one glance.