开发者

Matlab - partition a matrix [duplicate]

This question already has an answer here: Closed 11 years ago.

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, :];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜