LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Split 1D array and form 2D array

Hi,

 

How to split 1D array to 2D array, depending on the number specified.

 

e.g I want to group 2 data at a time.

 

1D array: 300 200 98 77 66 662 53 120 to

 

2D array: 300 200

              98   77

              66   662

              53   120

 

Thanks!!!

0 Kudos
Message 1 of 15
(4,129 Views)

You can use the "decimate 1D array" primitive (this will split your 1D array into 2 1D arrays) followed by a build array to "join" your two 1D arrays into a 2D array.

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 15
(4,126 Views)

Hi Titou,

 

what if I want more than 2 e.g 30?

0 Kudos
Message 3 of 15
(4,123 Views)

A 30 dimensions array?? Do you have a use case for that??

 

The decimate primitive is expandable so is the build array so you can do more than 2, but 30... sounds extreme.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 15
(4,119 Views)

I mean I got a 1D array with 900 data and want to group by 30.

That means every 30 data I want to turn it into a 1d array after that using all the 1d array I want to build a 2D array. How should I do that? 

0 Kudos
Message 5 of 15
(4,114 Views)

side note : apparently there are some users out there who use a higher than usual number of dimensions Smiley Surprised


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 15
(4,113 Views)

@Nextal wrote:

I mean I got a 1D array with 900 data and want to group by 30.

That means every 30 data I want to turn it into a 1d array after that using all the 1d array I want to build a 2D array. How should I do that? 


Oh, sorry... to do that you have to use a different technique. The "reshape array" is your friend, you candrag it down to add dimensions to the output array (2 in your case) and set the dimensions' size (30 and 30 in the case you mention).

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 7 of 15
(4,109 Views)

Hi Titou,

 

I am sorry for being not clear.

I have a 1D array with 900 row.

Every 30 row I want to create a 1D array.

So at the end I will have 30 1D array next I want to get a 2D array using this 30 1D array. How should I implement this?

0 Kudos
Message 8 of 15
(4,108 Views)

Sorry I didn't see you reply and post again I will try the reshape functions.

0 Kudos
Message 9 of 15
(4,105 Views)

Thanks, this is what I want. 🙂

0 Kudos
Message 10 of 15
(4,103 Views)