3D plotting

3D plotting
Recap 2D plotting
plot(x,y): given sequence of x and y values,
connects the dots (x(i),y(i))
Exercise: Plot a circle
Plot3: Plotting curves in 3D
plot3(x,y,z): Given a sequence of x,y,z values
connects the 3d dots (x(i),y(i),z(i))
Exercise: plot a cylindrical spiral. For a
cylindrical spiral
◦ x=cos(t), y=sin(t), z=t
Plot a conical spiral. For a conical spiral
◦ x=t cos(t), y=t sin(t), z=t
surf: Plotting surfaces in 3D
Load the elevation.mat from Assignment3
surf(map) plots the function map(i,j) vs j,I
Connects the dots by rectangular patches
◦ (j, i, h(i,j))
◦ (j, i+1, h(j,i+1)
(j+1, i, h(i,j+1))
(j+1,i+1, h(i+1,j+1))
Plotting z(x,y) vs x,y
Plot z=x^2+y^2 vs x,y
[X,Y]=meshgrid(x,y) returns the cartesian
product of the vectors x,y.
Plot the gaussian function. Its coordinates
are given by
◦ z=exp(-(x^2+y^2)/2)
◦ Assume x,y lie between -5 and 5
Plot a unit sphere. Its coordinates are
given by the equation
◦ x=cos(t)*cos(p), y=cos(t)*sin(p), z=sin(t)
◦ where –pi/2<= t <=pi/2 and 0<=p<=2*pi

similar documents