Hi,
I have a large matrix (14484×10) on this form:
[20031119 1 2 3 4 5 6 7 8 9;10 11 12 13 14 15 16 17 18 19;20 21 22 23 24 25 26 27 28 29;30 31 NaN NaN NaN NaN NaN NaN NaN NaN;20031120 1 2 3 4 5 6 7 8 9;10 11 12 13 14 15 16 17 18 19;20 21 22 23 24 25 26 27 28 29;30 31 NaN NaN NaN NaN NaN NaN NaN NaN;20031121 1 2 3 4 5 6 7 8 9;...and so on]
I want to rearrange the rows so that the first 4 rows turn makes the first row in the new matrix, the next 4 rows makes the second row etc, so that the resulting matrix looks like this:
[20031119 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31;20031120 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31;...and so on]
(I don't need the NaNs, but it's of course OK to keep them and delete them later.)
How do I do this? I have tried to do it using reshape, but it seems to me that reshape works columnwise and not rowwise.
I would appreciate any help!
Best Answer