从数据源中随机选择

时间:2012-07-11 21:32:53

标签: matlab dataset

  

可能重复:
  randperm subset of random m-by-n matrix

当试图从数据集“fulldata”中随机选择1000行时,我得到一个错误,我不太确定它是如何在matlab中完成的,但这是我尝试过的:

data = datasample(fulldata,6,1000)

全数据是490256x6,我想从这些数据中选择1000个随机行。在matlab中抛出错误

??? Undefined function or method 'datasample' for input arguments
of type 'double'.

Error in ==> randomselection at 44
data = datasample(fulldata,6,1000)

1 个答案:

答案 0 :(得分:3)

你可以改为使用这样的东西来获得它而不依赖于数据样本:

pointsToPick = 1000;  %# Numbers to pick
rVec = randperm(N);   %# Random permutation of datapoint indices (N=490256 in your case)  

randomSample = fulldata(rVec(1:pointsToPick),:); %# Random sample