选择数据集的百分比

时间:2012-11-27 22:09:43

标签: matlab octave

我是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

1 个答案:

答案 0 :(得分: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)';