LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to go from 3D Array to 2D Array

It is not clear what sorting means on a 3D array. Do you sort by page, row, or column?

LV has a built-in Sort 1D array.

Also, search the archives fo this forum. I think I recall that someone recently posted a 2D sort algorithm. Perhaps it could be adapted to your needs.

Lynn
0 Kudos
Message 11 of 15
(1,642 Views)

Thanks.

I totally overlooked that sorting array.

But I am curious how I can do that with my subvi, 3Ddata, from above post.  So would I do two while loops on the 3D data and than connect it with an index array, to get the first three columns, and sort array.

Does this make sense.

By the way, I have looked at the discussion board like you suggested, and I am still reading. But since I have an expert who answers back so quickly, I can't help but ask you.

Thanks.

0 Kudos
Message 12 of 15
(1,636 Views)
I am not sure I followed your description completely, but I think you are on the right track. I have never tried to sort a multi-dimensional array, but if you want to sort by a particular 1D array, select it, sort it, and use the results to sort the rest of the original array. You may need to create a "bookeeping" array of indices of the first array to assist.

Lynn
0 Kudos
Message 13 of 15
(1,628 Views)

Hello,

I have attached a notepad and a vi I created.

Curious to know how to get it so that all my 100 or 200 from each iteration is compared to one another when put side by side.

Am I on the right track with this subvi and how can I improve it to make it work to what I want.

Thanks.

Download All
0 Kudos
Message 14 of 15
(1,615 Views)
I am not sure what you want. When you say you want all the 100 compared do you mean you want to take all the rows with 100 in the first column and compare the data in the third columns of those rows?

Your file has 2D data, not 3D. If you take a 3D array and feed it to Array to Spreadsheet string you get something like this:

[0, 0, 0]
0.000 1.000 2.000 3.000 4.000
10.000 11.000 12.000 13.000 14.000
20.000 21.000 22.000 23.000 24.000
30.000 31.000 32.000 33.000 34.000
40.000 41.000 42.000 43.000 44.000

[1, 0, 0]
100.000 101.000 102.000 103.000 104.000
110.000 111.000 112.000 113.000 114.000
120.000 121.000 122.000 123.000 124.000
130.000 131.000 132.000 133.000 134.000
140.000 141.000 142.000 143.000 144.000

[2, 0, 0]
200.000 201.000 202.000 203.000 204.000
210.000 211.000 212.000 213.000 214.000
220.000 221.000 222.000 223.000 224.000
230.000 231.000 232.000 233.000 234.000
240.000 241.000 242.000 243.000 244.000

Where the numbers in brackets refer to the [page, row, column] indices of the next element. Your file does not have this and LV does not know how to interpret your data as 3D. That is why the first two lines in the text file do not appear in the array.

Lynn
0 Kudos
Message 15 of 15
(1,607 Views)