0

可能重复:
随机 m×n 矩阵的 randperm 子集

当尝试从数据集“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)
4

1 回答 1

3

您可以改为使用这样的方法来获取它,而无需依赖 datasample:

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
于 2012-07-11T22:52:18.693 回答