Reputation: 1277
I have a file, which has 310 blocks. And each of the blocks has 85 rows. Every row has ten numbers except for the last row.
I need to do some data process. I want to convert these blocks to 310 rows. So that is one rows for each block.
I know I can write this:
B(1,:)=[a(1,:),a(2,:),a(3,:)] to do the row combine job, but now I need to combine 85 rows, how can I write B(1,:)=[a(1,:),a(2,:),a(3,:),...,a(85,1:4)] in Matlab?
Thank you!
Upvotes: 0
Views: 46
Reputation: 36710
To linearise a matrix, you can use (:)
. To get the right order, its necessary to transpose fist.
h=a.'
B(1,:)=h(:)
To get everything up to a(85,4)
h=a.'
B(1,:)=h(1:sub2ind(size(h),4,85))
sub2ind transforms the matrix index to a linear index (single number).
Upvotes: 1