www.pudn.com > snippets(1).rar > scramble_subjects.m, change:2009-10-12,size:565b


function [new_data, new_class] = scramble_subjects(data, class, scramble_flag)
%
% randomly scramble subject ordering to avoid biases

num_subjects = length(data);

% initialize random number generator
rand('state',sum(100*clock));

% scramble, or leave ordering unchanged (to use saved bases etc.)
if scramble_flag
  new_order = randperm(num_subjects);
else
  new_order = 1:num_subjects;
end

new_data = cell(num_subjects,1);
new_class = cell(num_subjects,1);

for u = 1:num_subjects

  new_data{u} = data{new_order(u)};
  new_class{u} = class{new_order(u)};

end