function c = xblue_mag_red(m)
%XBLUE_MAG_RED a color spectrum from blue-magenta-red
%	XBLUE_MAG_RED(M) returns an M-by-3 matrix containing a
%	blue-magenta-red colormap.
%	XBLUE_MAG_RED, by itself, is the same length as the current colormap.
%
%	For example, to reset the colormap of the current figure:
%
%	          colormap(xblue_mag_red)
%
%	See also HSV, HOT, COOL, BONE, COPPER, PINK, FLAG, 
%	COLORMAP, RGBPLOT.

%     Copyright J. V. Mansbridge, CSIRO, Tue Aug  2 11:15:23 EST 1994

% a 32 color spectrum from blue-magenta-red                       

x = [
    0,   0,  95,     0,   0, 111,     0,   0, 127,     0,   0, 143,
    0,   0, 159,     0,   0, 175,     0,   0, 191,     0,   0, 207,
    0,   0, 223,     0,   0, 239,     0,   0, 255,    23,   0, 255,
   46,   0, 255,    69,   0, 255,    92,   0, 255,   115,   0, 255,
  138,   0, 255,   161,   0, 255,   184,   0, 255,   207,   0, 255,
  230,   0, 255,   255,   0, 255,   255,   0, 229,   255,   0, 204,
  255,   0, 178,   255,   0, 153,   255,   0, 127,   255,   0, 102,
  255,   0,  76,   255,   0,  51,   255,   0,  25,   255,   0,   0
];

x = reshape(x'/255, 96, 1);
if nargin < 1, m = size(get(gcf,'colormap'),1); end
mm = m - 1;
x_32 = (0:31)/31;
x_m = (0:mm)/mm;
r = interp1(x_32, x(1:3:94), x_m);
g = interp1(x_32, x(2:3:95), x_m);
b = interp1(x_32, x(3:3:96), x_m);
c = [ r g b ];
