function c = xrepeat(m)
%XREPEAT a color spectrum from 8 solid colors repeated 4 times.
%	XREPEAT(M) returns an M-by-3 matrix containing a repeat
%	colormap.
%	XREPEAT, by itself, is the same length as the current colormap.
%
%	For example, to reset the colormap of the current figure:
%
%	          colormap(xrepeat)
%
%	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 set of 8 solid colors repeated 4 times. It    
% is meant to be used for line contours while all the rest of the color
% spectra below are for graduated color fill plots.
% 8 colors are : brown, red, orange, yellow, green, cyan, blue, magenta

x = [
  165,  42,  42,   255,   0,   0,   255, 165,   0,   255, 255,   0,
    0, 255,   0,     0, 255, 255,     0,   0, 255,   255,   0, 255,
  165,  42,  42,   255,   0,   0,   255, 165,   0,   255, 255,   0,
    0, 255,   0,     0, 255, 255,     0,   0, 255,   255,   0, 255,
  165,  42,  42,   255,   0,   0,   255, 165,   0,   255, 255,   0,
    0, 255,   0,     0, 255, 255,     0,   0, 255,   255,   0, 255,
  165,  42,  42,   255,   0,   0,   255, 165,   0,   255, 255,   0,
    0, 255,   0,     0, 255, 255,     0,   0, 255,   255,   0, 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 ];
