How do I use the "search 1D array" primative?

7 replies to this topic

#1 alexber2

alexber2

I've come back for more.

• Members
• 2 posts
• Version:LabVIEW 2010
• Since:2011

Posted 15 April 2012 - 07:40 PM

Hi I want to say hello to everybody, due I'll be asking questions please be patient with me.
thanks
How I can use the function "search 1D array"?

Alejandro

#2 gb119

gb119

Extremely Active

• 256 posts
• Location:Leeds, UK
• Version:LabVIEW 2012
• Since:1995

Posted 15 April 2012 - 09:37 PM

Umm, you have a 1D array of something (e.g. floating point numbers) and you have a single element (e.g. a value) that may or may not be in the array. You wire the array to the array input, the elment (value) to the element input, you get out -1 if value wasn't found in the array or the index (i.e. the position within your 1D array starting at 0 for the first element in the list up to N-1 where N is the length of the array. If you want to limit your search to start not at the first element but somewhere in the middle of the array you wire the starting index (counting from zero) into the start index input. It works, albeit in a not very scalable way because it can't assume that the elements are ordered (or indeed are sortable at all). There's really not a whole lot one can say about it.
Gavin Burnell
Lecturer in Condensed Matter Physics
School of Physics and Astronomy
University of Leeds, UK
http://www.stoner.le...ac.uk/people/gb

#3 hooovahh

hooovahh

The 500 club

• Members
• 784 posts
• Version:LabVIEW 2011
• Since:2004

Posted 16 April 2012 - 02:35 PM

gb119 you have more patience than me. Copied from the LabVIEW help.

Searches for an element in a 1D array starting at start index. Because the search is linear, you need not sort the array before calling this function. LabVIEW stops searching as soon as the element is found.

You cannot use this function to retrieve the index of a value that is not an element of the array. For example, if you have an array of two elements (0.0 and 1.0), this function does not find the index of the value 0.5, as that value is not an element of the array. Use the Threshold 1D Array to find a fractional index.
This function only finds a string if the element you specify matches an array element exactly. For example, if you have an array of two elements (upper limit and lower limit), this function does not find the index of the value limit, because limit does not match an array element exactly. To search a string for any occurrence of a regular expression, such as in the previous example, use the Match Regular Expression function.

"Maybe Hoovah is really Crelf's alter-ego, which he uses to irk people?" - Gary Rubin

"Seemingly minor changes....can mean the difference between a working app and a quivering heap of unresponsive code." - David Boyd

#4 AustinCann

AustinCann

Very Active

• 62 posts
• Version:LabVIEW 2011
• Since:2009

Posted 21 April 2012 - 07:13 PM

I most often use it when I have an array of booleans or cluster of booleans( in which case I also use cluster to array function) and these are on the front panel and I want to trigger different events or conditions when each one of them is clicked. I use search 1d array function to determine if the boolean control is clicked. If index returned it not -1 I use case structure to define what I want to do.

I just tried to give an example of where this function could be used. Its a powerful function and could be used in many ways. Just use your imagination

#5 Saverio

Saverio

Enough LAVA to be dangerous

• Members
• 144 posts
• Version:LabVIEW 8.2
• Since:1994

Posted 02 May 2012 - 01:29 PM

Back for more homework help?

It sounds like you don't have much programming experience, so it's not clear what kind of answer you are expecting beyond what has already been said. The only other thing I will add is to not use this to search an array of floating point values. If you do not understand why that is, I'd suggest starting here: http://stackoverflow...actly-in-binary

#6 Prabhakant Patil

Prabhakant Patil

More Active

• Members
• 45 posts
• Version:LabVIEW 2010
• Since:2004

Posted 09 July 2012 - 06:16 AM

You can refer Labview help for the same.
It will give you single index as well as multiple index.

Prabhakant

#7 Saverio

Saverio

Enough LAVA to be dangerous

• Members
• 144 posts
• Version:LabVIEW 8.2
• Since:1994

Posted 09 July 2012 - 12:50 PM

Prabhakant, I suspect he probably finished his homework assignment by now.

#8 Prabhakant Patil

Prabhakant Patil

More Active

• Members
• 45 posts
• Version:LabVIEW 2010
• Since:2004

Posted 10 July 2012 - 04:47 AM

Ohh I forgot to see date when he posted his query.