LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search 1D array

I have two 1D array with named Master array and Slave array.

I would like to search each element in the Slave array with Master array.

if Master array does not have the element, I will append the element to the Master array.

Same way i would like to do for the all the elements in the Slave array.

 

So that resultant in the 1D array. Is there any VI available in Labview?.

 

0 Kudos
Message 1 of 13
(4,953 Views)

No, but it's pretty trivial to write something in LabVIEW. Use Search 1D Array to search your array. This will give you an index of the location, with -1 meaning it wasn't found. If not found use Build Array to add the element. Rinse and repeat for the other array.

 

I'd write you some code, but where's the fun for you? Smiley Wink Though I'm sure some other intrepid forum member will come along just itching to post an example. 

 

 

WARNING: You did not indicate the datatype of the elements. Search 1D Array should not be used for floating point values

 

 

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

Message Edited by smercurio_fc on 05-25-2010 09:39 AM
Message 2 of 13
(4,950 Views)

Kals wrote:

I have two 1D array with named Master array and Slave array.

I would like to search each element in the Slave array with Master array.

if Master array does not have the element, I will append the element to the Master array.

Same way i would like to do for the all the elements in the Slave array.

 

So that resultant in the 1D array. Is there any VI available in Labview?.


 

 
 You don't really give enough information to solve the problem. For example you don't specify in what order the elements should be inserted and if duplicate elements are allowed.
 
One possible interpretation would be to get a new array that contains all unique elements from both input arrays. This could be solved by concatenating the two arrays and removing all duplicate elements. This is relatively trivial and does not involve "search array" at all.
 
Could you specify more clearly what you actually want. Please attach a simple VI containing typical input data in two array controls and the desired output in an array indicator, manually enetered. Make current values the default, save, and attach. 
Message 3 of 13
(4,928 Views)
I have two 1d folder array. I want to merge both the 1d array without duplicates. please find the image.
i have tried with search 1d array.Is there any better solution?.
0 Kudos
Message 4 of 13
(4,913 Views)

As I said, attach a VI, not a picture.

 

Your code makes no sense at all. What is the purpose of the while loop???? You'll run out of elements within nanoseconds, so once stop is pressed, the output will be an empty string.

 

As I already said, all you need is to concatenate the two arrays (using build array in concatenate mode), sort the resulting array, then remove duplicates.

 

I believe there is an openG version for this, but you can also write your own. A simple template would be the second FOR loop found here. See image.

 

 

Message Edited by altenbach on 05-25-2010 08:59 AM
Message 5 of 13
(4,898 Views)

Specifically, here's what you could do in your particular applications:

 

 

 

 

Message Edited by altenbach on 05-25-2010 09:10 AM
Message 6 of 13
(4,879 Views)

If you're not in a hurry, append the arrays and remove any duplicates.  I used the OpenG "Remove Duplicates from 1D Array.vi"

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 7 of 13
(4,857 Views)

Thanks for the details. I will try to use open G VI's. There is a Tunnel specified in the case structure (inside the for loop).

by right clicking the tunnel If i enable the use default in the false case, i am getting null output.

May i know more details about the default values for the different variable type. I assume here it is string variable.

If it is the path variable what is the default. Is there any document to give details of the default conditions for the different variable types.

Thanks for the quick reply.

 

0 Kudos
Message 8 of 13
(4,796 Views)

Kals wrote:

There is a Tunnel specified in the case structure (inside the for loop).

by right clicking the tunnel If i enable the use default in the false case, i am getting null output.


 

 
Are you talking about my VI? As documented, you need to wire across in the FALSE case. If you use the default output, you'll loose all accumulated elements whenever the FALSE case executes. No, you are not getting "null", but an empty array of strings. 
 
All data types have intuitive defaults: "zero" for numerics, "empty string" for strings, "empty array" for arrays, "empty path" for paths. etc.
0 Kudos
Message 9 of 13
(4,781 Views)

I am able to visualiz the "zero" (example: 0) for numerics, "empty string"  (example: "") for strings, 

 

I am not able to visualize "empty array" for arrays, "empty path" for paths.

 

Whether the Path datatype is equvalent to string datatype?.

 

Could you give more details?. If you give details that would be great.

0 Kudos
Message 10 of 13
(4,771 Views)