Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D plotting.

Similar presentations


Presentation on theme: "3D plotting."— Presentation transcript:

1 3D plotting

2 Recap 2D plotting plot(x,y): given sequence of x and y values, connects the dots (x(i),y(i)) Exercise: Plot a circle >>t=linspace(0,2*pi,100); >>plot(cos(t),sin(t))

3 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 >>t=linspace(0,8*pi,500); >>x=cos(t); >>y=sin(t); >>z=t; >>plot3(x,y,z,’o-’);

4 Exercise Plot a conical spiral. For a conical spiral
x=t cos(t), y=t sin(t), z=t

5 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+1, i, h(i,j+1)) (j, i+1, h(j,i+1) (j+1,i+1, h(i+1,j+1))

6 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. >>x=linspace(-5,5,100); >>y=linspace(-3,3,50); >>[X,Y]=meshgrid(x,y); >>surf(X,Y,X.^2+Y.^2);

7 Exercise 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


Download ppt "3D plotting."

Similar presentations


Ads by Google