LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem to search in Array Clustering!!!

Solved!
Go to solution

Hi, 
I want to first thank you all in this forum for your help every time thank you very much.
As you saw in the title, I want to search in array of cluser as you see in picture, i means to search by the first element in the array in cluster and to find the indice of array of cluster ???
thank you.1.png2.png3.png

0 Kudos
Message 1 of 12
(5,315 Views)
Solution
Accepted by topic author Sarah_LAB

Hi Sarah,

 

it's not clear from your description which problems you encounter!

 

What do you want to search? What do you want to find?

What is your problem to index elements from your array?

 

In the images you (seem to) show a 1D array of cluster of 1D array of strings. You need to use IndexArray on the outer array, then Unbundle(ByName) on the cluster, then IndexArray on the inner array…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(5,291 Views)

i want to search by name of first element for example in picture (force or pression...) and to find the index of array of cluster . 

0 Kudos
Message 3 of 12
(5,284 Views)
Solution
Accepted by topic author Sarah_LAB

I'm not certain I understand your Data Structure, nor what it is you want to do.

 

I assume you are trying to use Search 1D Array.  This has the requirement that the Search Element exactly matches one (or more) elements of the Array being searched.  If your Array is an Array of Clusters, then it is looking for an exact match for one of the Clusters.

 

My first question is why do you have a Cluster in the first place?  It seems to consist of a single element, "tab", that is an Array of Strings (again, I'm guessing, but I see both "temper", a string, and "4", what appears to be a numeric, in the Array, and all Array elements have to be the same type, hence Array of String).  [Ah, a partial answer -- the Tab clusters might consist of Arrays of different lengths, and a 2D Array needs to be rectangular.  Of course, if you have fewer "temper" data, you can leave cells blank, a legitimate String value].

 

Of course, even if you get rid of the Cluster and create a 2D array of Strings, you still want to do a 1D search.  One way to do this is to create an "Index" array that consists of the first (non-numeric) element of each row/column (depending on how you arrange the 2D array), i.e. "temper", "pression", etc.  You search this 1D array, it says "temper is at position 0", so you know you need to look at row (or column) 0 of your 2D array.

 

Bob Schor

0 Kudos
Message 4 of 12
(5,280 Views)
Solution
Accepted by topic author Sarah_LAB

Something like this:

Search cluster.png/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 12
(5,275 Views)
Solution
Accepted by topic author Sarah_LAB

I see that the arrays are of different size.  So I understand doing the Array of Cluster of Array.  But what I would do is move the name out of the inner array.  It should be its own element in the cluster.  Then your array can be numeric (since it looks like you are just holding numeric data, it would make more sense this way).

 

So for searching, use a FOR loop and stop the loop when the desired name is found.  You should also have an indicator stating if the name was found.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 12
(5,273 Views)

0 Kudos
Message 7 of 12
(5,270 Views)

0 Kudos
Message 8 of 12
(5,261 Views)

@Sarah_LAB wrote:


Have to?  No.  Would it make your life (and whoever later has to figure out your code) easier?  Yes.

 

So my recommendation is an Array of Cluster of {String, Array of Numeric}  If you open the snippet in LabVIEW, you will see better what I mean.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 12
(5,257 Views)
Solution
Accepted by topic author Sarah_LAB

Hi , 
I found the solution ,
like this.
solution.png
Thank you for you all guys.


0 Kudos
Message 10 of 12
(5,252 Views)