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.

contour<br />

Remarks If you do not specify LineSpec, colormap and caxis control the color.<br />

2-312<br />

If X or Y is irregularly spaced, contour calculates contours using a regularly<br />

spaced contour grid, then transforms the data to X or Y.<br />

Examples To view a contour plot of the function<br />

z xe x2 y2 = ( – – )<br />

over the range –2 ≤ x ≤ 2, –2 ≤ y ≤ 3, create matrix Z using the statements<br />

[X,Y] = meshgrid(–2:.2:2,–2:.2:3);<br />

Z = X.∗exp(–X.^2–Y.^2);<br />

Then, generate a contour plot of Z.<br />

[C,h] = contour(X,Y,Z);<br />

clabel(C,h)<br />

colormap cool<br />

3<br />

2.5<br />

2<br />

1.5<br />

1<br />

0.5<br />

0<br />

−0.5<br />

−1<br />

−1.5<br />

−0.1<br />

−0.2<br />

−0.3<br />

−0.1<br />

−0.2<br />

−0.1<br />

−2<br />

−2 −1.5 −1 −0.5 0 0.5 1 1.5 2<br />

0 0<br />

0.1<br />

0.2<br />

0.3<br />

View the same function over the same range with 20 evenly spaced contour<br />

lines and colored with the default colormap jet.<br />

0.1<br />

0.4<br />

0.2<br />

0.1

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

Saved successfully!

Ooh no, something went wrong!