MATLAB矩阵有几十万行数据,想从中随机抽取2万行数据形成新的矩阵,用到什么函数?

如题所述

比如你那个大矩阵叫M。
S = size(M,1);
SampleRows = randperm(S);
SampleRows = SampleRows(1:20000);
SampleM = M(SampleRows,:);
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-05-17
row=floor(M*rand(1,20000)+1)(M表示原矩阵行数)随机产生行数,再获取这些行即可:new(i)=old(row(i),:)。