alexber2 Posted April 15, 2012 Report Share Posted April 15, 2012 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 Quote Link to comment
gb119 Posted April 15, 2012 Report Share Posted April 15, 2012 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. Quote Link to comment
hooovahh Posted April 16, 2012 Report Share Posted April 16, 2012 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. Quote Link to comment
KWaris Posted April 21, 2012 Report Share Posted April 21, 2012 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 Quote Link to comment
Saverio Posted May 2, 2012 Report Share Posted May 2, 2012 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.com/questions/1089018/why-cant-decimal-numbers-be-represented-exactly-in-binary Quote Link to comment
Prabhakant Patil Posted July 9, 2012 Report Share Posted July 9, 2012 You can refer Labview help for the same. Also attached example will help you to understand search array function. It will give you single index as well as multiple index. Prabhakant Search Array.vi Quote Link to comment
Saverio Posted July 9, 2012 Report Share Posted July 9, 2012 Prabhakant, I suspect he probably finished his homework assignment by now. Quote Link to comment
Prabhakant Patil Posted July 10, 2012 Report Share Posted July 10, 2012 Ohh I forgot to see date when he posted his query. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.