From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Split an array following one column condition

Solved!
Go to solution

Hi all,

 

I have a 2D array, and I would like to split this array into sub-arrays following 1st collum condition,

For example, the array is:

[1 a]

[2 b]

[1 c]

[2 a]

[2 e]

[3 h]

[5 t]

and we will need to split into  4 arrays below:

1st array:

[1 a]

[1 c]

 

2nd array:

[2 b]

[2 a]

[2 e]

 

3rd array: 

[3 h]

 

4th array:

[5 t]

 

and so on,...

 

Please see the picture,

 

Thanks for your help,

 

0 Kudos
Message 1 of 9
(1,466 Views)
Solution
Accepted by topic author tnn

Sort by the 1st column and then cut when the 1st column change value.

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

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 9
(1,425 Views)

Hi,

 

There are multiple ways to achieve, please find the one quick approach.

PalanivelThiruvenkadam_1-1672904376790.png

PalanivelThiruvenkadam_2-1672904406560.png

 

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 3 of 9
(1,423 Views)

Hi, Yamaeda,

 

Thanks for your suggestion,

I have finished it following your recommendation,

2023-01-06_10-54-06.png

 
0 Kudos
Message 4 of 9
(1,369 Views)

Thanks for your prompt reply,

 

However, If I follow that, I still cannot split the array,

Anyway, thank for your advice.

0 Kudos
Message 5 of 9
(1,367 Views)

Hi tnn,

 


@tnn wrote:

However, If I follow that, I still cannot split the array,


It always helps to simplify a VI:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(1,348 Views)
Solution
Accepted by topic author tnn

Hi tnn,

 

why can't you "split the array"?

Which error do you encounter?

Where are you stuck?

(Why did you need to use OpenG?)

 

Suggestion:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 9
(1,343 Views)
Solution
Accepted by topic author tnn

Here's what I would do (you can skip the sort if you want the output sorted by first appearance of the key):

 

To get each of the three grouped arrays, just index into the output and unbundle.

 

altenbach_0-1673030873910.png

 

 

 

Message 8 of 9
(1,301 Views)

Thank you all for your help,

 

I'm very appreciative of your suggestion,

 

This topic can be closed!

0 Kudos
Message 9 of 9
(1,258 Views)