function cmap = cyanred(m, k) %CYANRED Cyan-black-red colormap % cyanred(m,k) gives a cyan-grey-red colormap where the grey-level in % the middle is k % % cyanred(m) returns an m-by-3 matrix containing the colormap. % cyanred, by itself, is the same length as the current figure's % colormap (if no figure exists, MATLAB creates one). % The default m for MATLAB colormaps appears to be 64, but % something like 256 is visually smoother. % % colormap(cyanred) changes the current figure's colormap. % Ged Ridgway 2006 if nargin < 1 m = size(get(gcf,'colormap'),1); end if nargin < 2 k = 0; % default to black end % centre of colormap c = (m+1)/2; % lengths of smaller and larger parts (equal for even m) a = floor(c)-1; b = m-a; % red, green, blue r = [k*ones(1, a) linspace(k, 1, b)]; g = [linspace(1, k, b) k*ones(1, a)]; b = g; cmap = [r' g' b'];