I have two pieces of data. One is the actual fulldata
which is a dataset of 49625x6 numeric data, and the other is the index of that data with the target_class
Extract the 'normal' records using strmatch:
normIdx = strmatch('normal.', Book2);
normalSubset = fulldata(normIdx, :);
Then to generate a list of 250 random non repeating integers I googled "matlab list of non repeated random integers" and from the first result:
p = randperm(size(normalSubset , 1));
p = p(1:250)-1;
So now to get your 250 randomly selected normal records
normalSample = normalSubset (p, :);
normalSample
will be 250 x 6. now do the same with 'not normal.' to get a notNormalSample
(750 x 6) and then combine then to get
sample = [normalSample ; notNormalSample ]
So in sample
all the normals will appear before the not normals, if you want to mix them up use randperm()
again:
sample = sample(randperm(1000), :);