LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I restructure an unfavourable 2D array format to 1D?

Solved!
Go to solution

A surface profilometer we use produces data in text files with five columns with data point ordering by row first; i.e. if you have the following data sample;

 

1      2      3      4      5

6      7      8      9     10

11    12    13    14    15

 

Then the data order follows the number order here.  I want to chop up this annoying format into multiple arrays by row (depending on the number of rows = for loop?) then splice them back together as a single column (transpose these arrays then build array?). Help!

0 Kudos
Message 1 of 18
(4,131 Views)
Read from spreadsheet file and reshape array might be enough.
/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 18
(4,122 Views)

You've just described one solution. Autoindexing will take into account the number of rows present - you could easily build the for loop by taking the array size and feeding the number of rows to it, but autoindexing does this for you.

 

rearrange.png

---
CLA
0 Kudos
Message 3 of 18
(4,120 Views)

That's the other solution I'd thought of - find the array size of the input array, index array twice to find row and column sizes, then feed in as the dimension for Reshape Array.

---
CLA
0 Kudos
Message 4 of 18
(4,117 Views)

Are you asking how to take a 2-D array and transpose it?  If so, I recommend using the Transpose 2D Array function found on the Array Palette.  [I'm sure you already thought of that, which means that I don't understand your problem ...].

Transpose 2D Array.png

0 Kudos
Message 5 of 18
(4,087 Views)
Solution
Accepted by apg504

@apg504 wrote:

A surface profilometer we use produces data in text files with five columns with data point ordering by row first; i.e. if you have the following data sample;

 

1      2      3      4      5

6      7      8      9     10

11    12    13    14    15

 

Then the data order follows the number order here.  I want to chop up this annoying format into multiple arrays by row (depending on the number of rows = for loop?) then splice them back together as a single column (transpose these arrays then build array?). Help!


Once you have a 1D array, the concept of rows and columns no longer exists.

 

In any case, reshaping is the right thing. Here's what I would do: