1

我是 matlab 新手,我在文档中找不到任何内容,我有一种对数据集进行采样的方法,但我想知道如何使用百分比而不是使用直接数字:

normIdx = strmatch('normal.', TestDataLabels);
normalSubset = Testdata(normIdx, :);
normal = randperm(size(normalSubset , 1));
p = (normal(1:10000))'; % here I choose 10000 samples but I would like to use a percentage
4

1 回答 1

3

你的意思是这样吗?

pcnt = 75; % The percent of original data set size you wish your sample size to be
sampleN = ceil( (pcnt/100) * length(normal) ); % figure out what pcnt percent of original N is, and round upward

p = normal(1:sampleN)';
于 2012-11-27T22:32:30.710 回答