Home Reshaping array by horizontal slices (Matlab)
Reply: 0

Reshaping array by horizontal slices (Matlab)

user807 Published in April 22, 2018, 6:50 am

I am working with pretty big arrays of data, but here I'll consider a toy example.

Suppose a is 6x3 array:


I want to reshape it to the array of size (3,3,2) by horizontal slices, so that the resulting array b would be:

b(:,:,1)= [1,2,3;4,5,6;7,8,9]
b(:,:,2)= [10,11,12;13,14,15;16,17,18]

I was trying to do it with the reshape function: b=reshape(a,[3,3,2]), however, the resulting array is different (in goes though columns first).

I didn't really find the appropriate options for the reshape function. Is there a nice solution to this issue? I know how to do it with a single for loop.


You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299416 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO