You can treat this as a random simulation problem. You pick three (four) datasets and find the largest cross-correlation score, which I define as sum of pairwise correlation score.
max_score = 0;
max_set = [];
max_prev = 0;
counter = 0;
while 1,
idx = randperm(10);
idx = idx(1:3); % or 1:4 for case of four
score = R(idx(1), idx(2)) + R(idx(2), idx(3)) + R(idx(1), idx(3));
if score > max_score,
max_score = score;
max_set = idx;
end
counter = counter + 1;
if mod(counter, 1000) == 0, % every 1000 iteration check convergence
if max_score - max_prev < 0.0001,
break;
end
end
max_prev = max_score;
end
Althought it is not a deterministic process, it doesn't take long to converge and give you global optimal.