Matlab - partition a matrix [duplicate]
Possible Duplicate:
How can I divide/split up a matrix by rows be开发者_如何学Ctween two other matrices?
I have a matrix A with 100 rows, I want to randomly partition it into 2 matrices, one that will have 70 of the rows of A, and the other that will have the remaining 30 rows. How is this done?
Its quite some time that I really used Matlab, but this should work: At first we look for a random number to split the matrix. Then we store all rows up to this factor in B, the rest is stored in C
split = round(rand(1)*100);
B = A[1:split, :];
C = A[(split+1):100, :];
精彩评论