matthiasm@8: function [train, test] = rnd_partition(data, train_percent); matthiasm@8: % function [train, test] = rnd_partition(data, train_percent); matthiasm@8: % matthiasm@8: % data(:,i) is the i'th example matthiasm@8: % train_percent of these columns get put into train, the rest into test matthiasm@8: matthiasm@8: N = size(data, 2); matthiasm@8: ndx = randperm(N); matthiasm@8: k = ceil(N*train_percent); matthiasm@8: train_ndx = ndx(1:k); matthiasm@8: test_ndx = ndx(k+1:end); matthiasm@8: train = data(:, train_ndx); matthiasm@8: test = data(:, test_ndx);