function res = discretize_matrix(tab,fun,no_of_bins)
  min_vec = min(tab);
  max_vec = max(tab);
  mean_vec = mean(tab);
  std_vec = std(tab);
  median_vec= median(tab);
  for i=1:(size(tab)(1))
    res(i,1) = floor(tab(i,1));
    for j=1:(size(tab)(2))
      res(i,j) = feval(fun,no_of_bins,tab(i,j),min_vec(j),max_vec(j),mean_vec(j),std_vec(j),median_vec(j));
    endfor
  endfor
endfunction
