0001 function cmap_idx = data2cmap(data,map_size,clim)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 try map_size(1); catch map_size = 64; end;
0012 try clim(1); catch clim = []; end;
0013
0014
0015 if isempty(clim)
0016 cscale = linspace(min(data(:)), max(data(:)), map_size);
0017 else
0018 cscale = linspace(clim(1),clim(2),map_size);
0019 end
0020
0021 [count,bin_idxs] = histc(data(:),cscale);
0022
0023
0024 bin_idxs(data < min(cscale)) = 1;
0025 bin_idxs(data > max(cscale)) = map_size;
0026
0027 cmap_idx = reshape(bin_idxs,size(data));
0028
0029 return