0% found this document useful (0 votes)
9 views

3D Graphgcdg h

The document provides an overview of high-level 2-D and 3-D plotting facilities in MATLAB, focusing on contour plots, meshgrid, and subplots. It includes examples for creating contour plots of specific functions and demonstrates how to combine multiple plots in one figure. Additionally, it covers 3-D plotting techniques using mesh and surf commands for surface modeling.

Uploaded by

Grenlighttt
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

3D Graphgcdg h

The document provides an overview of high-level 2-D and 3-D plotting facilities in MATLAB, focusing on contour plots, meshgrid, and subplots. It includes examples for creating contour plots of specific functions and demonstrates how to combine multiple plots in one figure. Additionally, it covers 3-D plotting techniques using mesh and surf commands for surface modeling.

Uploaded by

Grenlighttt
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

High-level 2-D

plotting facilities
Contour Plots

contour plot: is a plot of the level curves of the function.

For example: the level curves of are circles centered at the origin, and the levels are the squares of
the radii of the circles.

Contour plots are produced in MATLAB with meshgrid and contour.

[x, y] : x, y interval
contour(list of independent variables,
dependent variable, sequence of of levels)
Meshgrid – Contour

EXAMPLE : To plot the lemniscate


x^2 − y^2 = (x^2 + y^2)^2
or (x^2 + y^2)^2 − x^2 + y^2 = 0

axis square
title('The lemniscate x^2-y^2=(x^2+y^2)^2')
X=-1.1:0.01:1.1;
Y= 1.1:0.01:1.1;
[X Y] = meshgrid(X, Y);
Z= (X.^2 + Y.^2).^2 - X.^2 + Y.^2
contour(X, Y,Z, [0 0])
Multiple plots in a same figure: subplot
subplot(m, n, p) divides the figure window into m×n
small sets of axes, and selects the pth set for the
current plot (numbered by row from the left of the top
row).

Draw two graph for the following dependent and


independent variables x is betwen 0 and 1 and
increment is 0.1 : y=x^2; Z=x^3;
Combining Plots in One Window

Subplot : subplots can also be


created using the Figure Palette,
which you can enable from the
View menu.
High-level 3-D plotting facilities.
Three-DImensIonal WIREFRAME Plots : plot3(x,y,z)
(It takes three vectors instead of two.)
EXAMPLE T = -2:0.01:2;
x=cos(2*pi*T);
y=sin(2*pi*T);
plot3(x, y, T); OR plot3(cos(2*pi*T), sin(2*pi*T),T)
3-D Plots : Surface modelling

Basic commands for plotting surfaces in 3-space: mesh & surf

There are two different ways of using each command: z-coordinate is


given as a function of x and y. x, y, and z are all given as functions of two
other parameters.

To plot z = f(x, y), one begins with a meshgrid command as in the case of
contour.

For example: [x,y] = meshgrid(-2:0.1:2, -2:0.1:2);


z = x.ˆ2 - y.ˆ2;
mesh(x, y, z)

(MATLAB shades the surface with a color scheme depending on the z-coordinate.
surf (): We could have produced an opaque
surface instead by replacing mesh with surf.

You might also like