Hi
Say I have a 200×8 matrix A. I want to split it up into (for instance) 10 parts, as follows:
[Rows 1-20 and all 8 columns, Rows 21-40 and all 8 columns, …, Rows 181-200 and all 8 columns].
Let's write this as:
[20×8 submatrix 1, 20×8 sumatrix 2, … , 20×8 submatrix 10]
in a next step, I want to concatenate all rows of each submatrix such that I get:
[160×1 submatrix 1, 160×1 submatrix2, …, 160 submatrix 10]
The numbers are just examples of course. So currently, I do it like this:
nrSplits = 10; %split up original matrix into 10
nrColumns = 8;A = randn(200,8);y = 200:nrSplits; for i = 1:nrSplits foo = A(1+y*(i-1):y*i,1:nrColumns); foo = foo(:); ASplit(i,:) = foo; end
..which works, but it seems to me a bit inefficient and clumsy. Is there a better way to do this? Maybe there are functions which would be helpful but I don't know of..?
Many thanks
Best Answer