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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

f( x, y)<br />

31 ( – x)<br />

2e x2 – ( y + 1)<br />

2 – 10 x<br />

-- x3 – y5 ⎛ – ⎞ex2 – y2 =<br />

–<br />

–<br />

ezcontourf<br />

ezcontourf requires a string argument that expresses this function using<br />

<strong>MATLAB</strong> syntax to represent exponents, natural logs, etc. This function is<br />

represented by the string:<br />

f = ['3*(1−x)^2*exp(−(x^2)−(y+1)^2)',...<br />

'− 10*(x/5 − x^3 − y^5)*exp(-x^2−y^2)',...<br />

'- 1/3*exp(−(x+1)^2 − y^2)'];<br />

For convenience, this string is written on three lines and concatenated into one<br />

string using square brackets.<br />

Pass the string variable f to ezcontourf along with a domain ranging from −3<br />

to 3 and specify a grid of 49-by-49:<br />

y<br />

ezcontourf(f,[-3,3],49)<br />

3<br />

2<br />

1<br />

0<br />

−1<br />

−2<br />

⎝5⎠ 3 (1−x) 2 exp(−(x 2 ) − (y+1) 2 )− ~~~ x 2 −y 2 )− 1/3 exp(−(x+1) 2 − y 2 )<br />

−3<br />

−3 −2 −1 0<br />

x<br />

1 2 3<br />

1<br />

--e ( x + 1)<br />

3<br />

2 – y2 –<br />

–<br />

In this particular case, the title is too long to fit at the top of the graph so<br />

<strong>MATLAB</strong> abbreviates the string.<br />

2-521

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

Saved successfully!

Ooh no, something went wrong!