LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Icon

Is there any icon that i could convert 2D array to 1D array..
 
thanks ..
:manhappy:
0 Kudos
Message 1 of 9
(4,020 Views)
Hi Rep...,

yes: it's called 'Reshape Array'!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(4,016 Views)
"Converting" a 2D to a 1D array is not a well defined operation, so maybe you should tell us how the elements of the 2D array should be arranged in the 1D array.
  • "Reshape array" (see image) will basically append all the rows. Is that what you want?
  • If you e.g. have a 1 x N or N x 1 2D array and want is as a 1D array of size N, you could use "index array".

What are your requirements?

Other possible intepretations are e.g.: average all rows (or columns) of the 2D array to yield a 1D array.

Message Edited by altenbach on 11-01-2006 12:41 AM

Message 3 of 9
(4,013 Views)

Hello All!

 

I have a similar problem with arrays. My problem is:

I have a 2D array(size 5X8) called message and a 1D array(size 4) called input 1D array. My application requires that I multiply evry element in the 2D array with the whole(all elements of 1D array). As you can see in the picture attached, I have two for loops auto indexed on the rows and colums of the 2D array respectively. I pass in the 1D array in to the inside for loop without auto indexing. This works fine. However, the problem is that at the output . Every time it multiplies an element (of 2D array)with the 1D array, it goes to a new row, where as I want it to continue in the same row until it reaches to the end of that particular row in the 2D array.

 

For example, to make it clear: say message = 1 0 1 1 1 0 1 1

                                                                           1 0 0 0 1 0 1 0

 

and 1D input array = [100 200 100  500]

 

Then I need the output array =  100  200 100  500 0 0 0 0  100 200 100  500 100 200 100 500 100 200 100 500 0 0 0 0 100 200 100 500 100 200 100 500

                                                   100  200 100 500 0 0 0 0   0     0     0      0     0    0      0    0      100 200 100 500 0 0 0 0 100 200 100 500 0     0     0      0

 

 

How ever, LabView gives:         100 200 100 500

                                                    0    0      0    0

                                                   100 200 100 500

                                                   100 200 100 500

                                                   100 200 100 500

                                                    0    0      0     0

                                                   100 200 100 500

                                                   100 200 100 500

 

How can I fix this? Im really stuck. Any help would be really appreciated!!!

0 Kudos
Message 4 of 9
(3,509 Views)

Hi LSASS,

 

have you read Altenbachs message just before adding your question? Then the picture he included should give you all you need: just reshape your 2d result to a 1d array (it will append all the rows into just one row)...

 

But you may also use a shift register and a "build array" to get your 1d array - decide what is easier to you...

Message Edited by GerdW on 04-17-2009 11:45 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 9
(3,504 Views)

Actually, he's trying to go from a 3D array to a 2D array, but the concept is the same. You just have to give it the right number of rows and columns: