LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Rows to Columns

I have an array which has data in 17 rows with the first being time and the next 16 being input from the respective analog channels. What I Want to do is reshape the array to make the first COLUMN time and each subsequent column data for a channel. I have been messing around with reshape array but have had no luck. Any help would be appreciated. Thanks.
Intern NSWCCD Carderock.
0 Kudos
Message 1 of 8
(4,032 Views)
I'm presuming that your data is in a 2D array. If so use the Transpose 2D Array function in the array palate to change from "2D array [i,j] to transposed array[j,i]

P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 2 of 8
(4,029 Views)
Thanks for the quick reply!
Intern NSWCCD Carderock.
0 Kudos
Message 3 of 8
(4,023 Views)

I want to do the same thing with my data, i.e. convert rows to columns. 

But in my case, data is not a 2D array it is 4 or more rows that I need to format into columns. 

I know about the 2D transpose function but how do we transpose 4D array? 

Thanks! I appreciate any input.  

0 Kudos
Message 4 of 8
(2,862 Views)

I think you4 terminology is confused.  A 4D array is not 4 rows.  It is an array that requires 4 indices.  (column, row, page, volume)  4D arrays are pretty rare in programming.  I have generated one myself for a project, but that is the only time in 35 years of programming.

 

It sounds like you do actually have a 2D array.

 

Did you try Transpose Array?

 

If you still think it doesn't work for you, then post a VI that contains your data saved as default, and shows what you want the data to look like after.

0 Kudos
Message 5 of 8
(2,857 Views)

I have data in 4 rows... 

I want to format them into columns as shown below:

lodhi33_1-1604029357502.png

 

 

I know this can be done in the excel file with a single click but I wanted to do this in the labview program... 


I also wanted to add strings to the start of my data rows (/to be columns) so I can name the rows according to data type they are (shown in yellow highlight). It would be nice if you had any pointers on how to do that? Thank you so much! 

0 Kudos
Message 6 of 8
(2,852 Views)

I think I found a solution to transposing a large number of rows. I think I am going to convert my array to a matrix, transpose it, then convert matrix back to array for writing to my CSV file. 

 

Thank you! 

I would still appreciate if anyone has the answer to my question about appending a string to the start of your data row... How do I mark what row is what using text while my data is being written to a file? (add a name for each trace?)

 

 

lodhi33_0-1604030804740.png

 

0 Kudos
Message 7 of 8
(2,848 Views)

Hi lodhi,

 


@lodhi33 wrote:

I think I found a solution to transposing a large number of rows. I think I am going to convert my array to a matrix, transpose it, then convert matrix back to array for writing to my CSV file. 


No need to convert your 2D array into a matrix just for transposing: you can transpose 2D arrays as easily!

 


@lodhi33 wrote:

I would still appreciate if anyone has the answer to my question about appending a string to the start of your data row...


In an array all elements are of the same datatype: you cannot mix strings with numeric data in the same array.

Possible solutions:

  1. Convert the numeric array into a string array, then use BuildArray to prepend the row of column headers.
  2. When it is all about saving to a file: first save the row of column headers (as strings), then write/append the numeric array into the same file…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 8
(2,823 Views)