function c = xrainbow(m)
%XRAINBOW a color spectrum from red-orange-yellow-green-cyan-white      
%	XRAINBOW(M) returns an M-by-3 matrix containing a rainbow
%	spectrum red-orange-yellow-green-cyan-white colormap.
%	XRAINBOW, by itself, is the same length as the current colormap.
%
%	For example, to reset the colormap of the current figure:
%
%	          colormap(xrainbow)
%
%	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 rainbow spectrum red-orange-yellow-green-cyan-white           

x = [
  159,   0,   0,   175,   0,   0,   191,   0,   0,   207,   0,   0,
  223,   0,   0,   239,   0,   0,   255,   0,   0,   255,  33,   0,
  255,  66,   0,   255,  99,   0,   255, 132,   0,   255, 165,   0,
  255, 183,   0,   255, 201,   0,   255, 219,   0,   255, 237,   0,
  255, 255,   0,   204, 255,   0,   153, 255,   0,   102, 255,   0,
   51, 255,   0,     0, 255,   0,     0, 255,  51,     0, 255, 102,
    0, 255, 153,     0, 255, 204,     0, 255, 255,    51, 255, 255,
  102, 255, 255,   154, 255, 255,   204, 255, 255,   225, 255, 255
];

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 ];
