Home > FA-MVEMD > 3D > redblue.m

# redblue

## PURPOSE

REDBLUE Shades of red and blue color map

## SYNOPSIS

function c = redblue(m)

## DESCRIPTION

    REDBLUE    Shades of red and blue color map
       REDBLUE(M), is an M-by-3 matrix that defines a colormap.
       The colors begin with bright blue, range through shades of
       blue to white, and then through shades of red to bright red.
       REDBLUE, by itself, is the same length as the current figure's
       colormap. If no figure exists, MATLAB creates one.

       For example, to reset the colormap of the current figure:

                 colormap(redblue)

       See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG,
       COLORMAP, RGBPLOT.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- EMD2D2V Purpose:
- EMD2D3V Purpose:
- EMD3D3V Purpose:

## SOURCE CODE

    0001 function c = redblue(m)
    0002 %REDBLUE    Shades of red and blue color map
    0003 %   REDBLUE(M), is an M-by-3 matrix that defines a colormap.
    0004 %   The colors begin with bright blue, range through shades of
    0005 %   blue to white, and then through shades of red to bright red.
    0006 %   REDBLUE, by itself, is the same length as the current figure's
    0007 %   colormap. If no figure exists, MATLAB creates one.
    0008 %
    0009 %   For example, to reset the colormap of the current figure:
    0010 %
    0011 %             colormap(redblue)
    0012 %
    0013 %   See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG,
    0014 %   COLORMAP, RGBPLOT.
    0015
    0016 %   Adam Auton, 9th October 2009
    0017
    0018 if nargin < 1, m = size(get(gcf,'colormap'),1); end
    0019
    0020 if (mod(m,2) == 0)
    0021     % From [0 0 1] to [1 1 1], then [1 1 1] to [1 0 0];
    0022     m1 = m*0.5;
    0023     r = (0:m1-1)'/max(m1-1,1);
    0024     g = r;
    0025     r = [r; ones(m1,1)];
    0026     g = [g; flipud(g)];
    0027     b = flipud(r);
    0028 else
    0029     % From [0 0 1] to [1 1 1] to [1 0 0];
    0030     m1 = floor(m*0.5);
    0031     r = (0:m1-1)'/max(m1,1);
    0032     g = r;
    0033     r = [r; ones(m1+1,1)];
    0034     g = [g; 1; flipud(g)];
    0035     b = flipud(r);
    0036 end
    0037
    0038 c = [r g b];
    0039