Suppose I have a 4x2x2 array such that
val(:,:,1) =
1.0000 18.2190
1.0000 15.4650
12.0223 76.2841
64.1669 104.7139
val(:,:,2) =
1.0000 18.2190
18.2190 18.6414
11.5436 74.6475
74.7046 110.4268
I am trying to "flatten" this 3D array into a 2D array so that it looks something like this
val(:,1) =
1.0000
18.2190
1.0000
15.4650
12.0223
76.2841
64.1669
104.7139
Is there a shorthand method for doing this so I can avoid using for-loops?
You can also use pagetranspose which makes it very short:
reshape(pagetranspose(val),[],1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With