MATLAB: Restructure array

arrays

How can I reorganize the following array?
A= [m1; m2][n1; n2; n3][p1; p2; p3][q1; q2; q3; q4]
into
B =[m1; n2; p1; q1][m2; n2; p2; q2][n3; p3; q3][q4]
Thank you

Best Answer

Unless those variables indicate vectors or arrays with harmonious sizes, neither of those arrays is allowed: numeric arrays cannot be varying length.
What do you intend your notation for A to mean? The notation you give is not valid MATLAB notation. Are you trying to indicate a 3 dimensional array, such as would be formed by
cat(3, [m1;m2], [n1;n2;n3], [p1;p2;p3], [q1;q2;q3;q4])
(but only if the sizes happen to match up) ?