LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Group 1d array elements by row


@Asasafuchi wrote:

Thanks! This seems to work and is definitely more clear than my code. However I do have a follow up question: If instead my input was a 2D array with the following format: 


This is not clear at all, because in the original problem we create multiple columns from one row. If the input has multiple columns, but each row only occupies one of the columns, how exactly should groups be arranged. It seems unusual if both conditions can be fulfilled.

 

Can you give an example with more input fields?

 

In any case, you could just add an additional item that indicates the original column to the intermediary cluster and use that to place the elements at the very end into a 2D array of the correct size. Should be quite a trivial change to my code.

0 Kudos
Message 21 of 26
(92 Views)

Asasafuchi_0-1735585921666.png

So the objective is the same: append elements of the same type (same letter and interval requirement fulfilled) but the difference is that the input will be a 2d array instead of a 1d array. The grouping logic should be as follows: if an element belongs to the same group as another it should be appended to the row of the first occurence of this group type, for example: A[0-10] and A[20-40] are the same, A[20-40] gets appended to the row of A[0-10] because A[0-10] comes first and it gets appended to the second column because that was its original place. The input array will be structured such that each column only contains unique elements, so grouping them would mean only moving the row index of one element to another (notice how column 1 only contains elements of different groups).

0 Kudos
Message 22 of 26
(72 Views)

So did you try my idea?

 

If you want help, make my life easier and attach a simple VI containing the new inputs and desired outputs as default values. (No code, except for the terminals).

It is a waste of my time trying to read text from a screenshot and there are possibilities for typos!

0 Kudos
Message 23 of 26
(68 Views)

Yes, I tried your idea by adding a new 1d array containing each elements original column index but I couldnt successfully implement it. At any rate, here is an example VI containing the new inputs and outputs with default values. Sorry for the confusion.

0 Kudos
Message 24 of 26
(45 Views)

It seems you changed the format, because now there is no space after the first letter. How much variation do you expect in the formatting?

It still does not make sense to have a distance that is orange. It is an integer.

 

0 Kudos
Message 25 of 26
(33 Views)

You are right, there should be a space between the letters and the brackets. This was just an oversight on my part, no variation in the input will exist so hardcoding the scan from string like you did will still work. I have attached the same vi but with spaces added.

0 Kudos
Message 26 of 26
(4 Views)