% divideset.m 

% function for dividing 'data' to 'train' and 'test' set
% how many percents goes to training set is determined
% by threshold

function [test, train] = divideset(data, threshold)

[x, y] = size(data);
rnd = rand(1, x);
[rnds, srt] = sort(rnd);

threshold = round(x * threshold / 100);

trn = find(rnd < rnds(threshold));
tst = find(rnd >= rnds(threshold));

train = data(trn, :);
test = data(tst, :);