LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to take out a subset in front of and behind a number you searched for in an array.

Solved!
Go to solution

Hi,

  A search didn't give me anything so I apologize if it is in there somewhere and I can't find it.  I am using LabVIEW 7.1 and am searching an array for a given value.  Once I find that value in the array I want to take out 51 values with the one that I found in the search being in the center. Is there an easy way to do this?  The current way I am trying to do it is by using search array and then inputting that index into the array subset function with a length of 51.  Of course I want to get 25 data points before and 25 after what I searched for, not 50 after.  What is the most efficient way to do this?  Should I branch off the index of my search result into two sub array vi's.  One being the index-25 and the index and then set the length of both sub-array's to 25?  Thanks for any advice regarding the matter.  Sam

0 Kudos
Message 1 of 4
(2,238 Views)
Solution
Accepted by topic author sayndesyn
Why don't you just subtract 25 from the index at which your value was found, and use that as start index for array subset?  You'll have to deal with the situation where your desired value is found at less than 25 points in but that should be easy enough depending on how you want to handle it.
Message 2 of 4
(2,234 Views)

Sam,

 

searching for the numeric value first is ok. But you should not yet extract any part of the array...

Once you found the value, you will get the index of the value (the place of the value within the array). You should then check if

- the index is less than 26

- the index is greater than (size of array - 25)

If both "ifs" are not applying, just build a subarray with startindex = index(value) - 26 and with a length of 51.

Regarding of the "if" which is not applying, the "bandwidth" around index(value) should be adopted....

 

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 3 of 4
(2,233 Views)

Thanks Guys,

  The process where the search starts isn't going to happen until I am 200 points into the array so pulling a subset that doesn't exist yet shouldn't be a problem.  Thanks again, I'll consider this issue solved, both replies helped.

0 Kudos
Message 4 of 4
(2,227 Views)