function [out_index] = cluster_modis_elements(data, index, num)

num_index = length(index);
cmask = zeros(num_index, 1);
cmask(:) = data(index);

out_index = cell(num, 1);
for n = 1:num
  ind = find(cmask == n);
  len = length(ind);
  tmp = zeros(len, 1);
  tmp(:) = index(ind);
  out_index{n} = tmp;
end

