23.12.2012 Views

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

each time they render. CData values equal to or less than cmin map to the first<br />

color value in the colormap, and CData values equal to or greater than cmax<br />

map to the last color value in the colormap. <strong>MATLAB</strong> performs the following<br />

linear transformation on the intermediate values (referred to as C below) to<br />

map them to an entry in the colormap (whose length is m, and whose row index<br />

is referred to as index below).<br />

index = fix((C–cmin)/(cmax–cmin)∗m)+1<br />

Examples Create (X,Y,Z) data for a sphere and view the data as a surface.<br />

[X,Y,Z] = sphere;<br />

C = Z;<br />

surf(X,Y,Z,C)<br />

Values of C have the range [−1 1]. Values of C near −1 are assigned the lowest<br />

values in the colormap; values of C near 1 are assigned the highest values in<br />

the colormap.<br />

To map the top half of the surface to the highest value in the color table, use<br />

caxis([−1 0])<br />

To use only the bottom half of the color table, enter<br />

caxis([−1 3])<br />

which maps the lowest CData values to the bottom of the colormap, and the<br />

highest values to the middle of the colormap (by specifying a cmax whose value<br />

is equal to cmin plus twice the range of the CData).<br />

The command<br />

caxis auto<br />

resets axis scaling back to auto-ranging and you see all the colors in the<br />

surface. In this case, entering<br />

caxis<br />

returns<br />

[–1 1]<br />

caxis<br />

2-215

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!