Surface Plot

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Surface Plots with MATLAB

We will plot the surface of equation z = x2 y 2 as well as the level curves for c = 2, 1, 0, 1, 2. In MATLAB, to get a rectangular domain 2 x 2, 2 y 2 in steps of 0.2, we use the command >> [x, y] = meshgrid([-2:0.2:2],[-2:0.2:2]); We calculate z = x2 y 2 as follows (note the use of .s). >> z = x.^2 - y.^2; To obtain the surface plot, we use either of the following. >> mesh(x,y,z) >> surf(x,y,z) %this one has colors

To plot the level curves for c = 2, 1, 0, 1, 2, we use the following commands. >> [c,h]=contour(x,y,z,[-2,-1,0,1,2]); >> clabel(c,h) %this labels the c values on the contour plot
2
0

1.5 4 1 3
2

-2
0

-2

-1

-1
0
1

2 1

0.5
0

0 -1 -2 -3 -4 2 1 0 0 -1 -2 -2 -1 1 2

0
0

-0.5
1

-1

-1
0

-1.5

-1
-2

-2

-1
-0.5 0 0.5 1 1.5 2

-2 -2

-1.5

-1

The plot of the surface of equation 20 3 + x2 + 2y 2 as well as the level curves for c = 1, 2, 3, 4, 5 are shown below. z=
5

7 6 5

2
2

3
1 4 0 3
5

2 1 0 5 5

-1
4

-2
1

2
1

-3

-4 0 0 -5 -5 -5 -5 -4 -3 -2 -1 0

Gilles Cazelais. Typeset with L T X on February 5, 2007. A E

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy