LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I search 1D array

I have a 1D array of elements from 1 to 100. each number is repeated
more than once in the array. i want to search the index when a new
number is found for the first time in my array. if my array is
{1,1,1,2,2,2,2,3,3,3,3,3,4,4,5,5,5,5....} i want to find the index
when 1,2,3,4,5,.... are occured for the first time. when i use search
1D array function and put that in a loop and increment every time the
search element the index i am reading is always -1.
0 Kudos
Message 1 of 4
(2,856 Views)
Try this example. As long as you don't have a -1 in your array. If
you do place another constant that isn't in the array. Hope this
helps.
0 Kudos
Message 2 of 4
(2,856 Views)
Without seeing your program, it's hard to say what you're doing wrong
but you should be able to do soemthing similar to what I show in the
attachment.
0 Kudos
Message 3 of 4
(2,856 Views)
> I have a 1D array of elements from 1 to 100. each number is repeated
> more than once in the array. i want to search the index when a new
> number is found for the first time in my array. if my array is
> {1,1,1,2,2,2,2,3,3,3,3,3,4,4,5,5,5,5....} i want to find the index
> when 1,2,3,4,5,.... are occured for the first time. when i use search
> 1D array function and put that in a loop and increment every time the
> search element the index i am reading is always -1.

I'm not sure exactly what you are looking for, so here are some options.

If you want to find the single index in the array where you have seen
all of the values below a value, then build a small state machine with
the state indicating what data values have been seen. Within the
states, look
for the next value. When you get to the last value, report
the index.

If you are instead looking for adjacent items, for a certain pattern,
you might want to use the correlation VIs.

If you are looking for the set of indices where each of the items first
occurs, then you probably do want to use Search 1D Array, and make sure
that the index builds into an array so you will have all of them, not
just the last. At any point, if you search for an element that isn't in
the array beyond the position, then the node will return a -1.

Greg McKaskle
Message 4 of 4
(2,856 Views)