05-25-2010 09:32 AM
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?.
05-25-2010 09:37 AM - edited 05-25-2010 09:39 AM
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? 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.
05-25-2010 10:05 AM
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?.
05-25-2010 10:43 AM
05-25-2010 10:57 AM - edited 05-25-2010 10:59 AM
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.
05-25-2010 11:10 AM - edited 05-25-2010 11:10 AM
Specifically, here's what you could do in your particular applications:
05-25-2010 12:23 PM
If you're not in a hurry, append the arrays and remove any duplicates. I used the OpenG "Remove Duplicates from 1D Array.vi"
05-26-2010 10:28 PM
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.
05-27-2010 01:08 AM
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.
05-27-2010 02:02 AM
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.