3d plotting. recap 2d plotting plot(x,y): given sequence of x and y values, connects the dots...

7
3D plotting

Upload: shanon-gibbs

Post on 22-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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 >>t=linspace(0,2*pi,100);

3D plotting

Page 2: 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 >>t=linspace(0,2*pi,100);

Recap 2D plottingplot(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))

Page 3: 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 >>t=linspace(0,2*pi,100);

Plot3: Plotting curves in 3Dplot3(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-’);

Page 4: 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 >>t=linspace(0,2*pi,100);

ExercisePlot a conical spiral. For a conical

spiral◦x=t cos(t), y=t sin(t), z=t

Page 5: 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 >>t=linspace(0,2*pi,100);

surf: Plotting surfaces in 3DLoad 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))

Page 6: 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 >>t=linspace(0,2*pi,100);

Plotting z(x,y) vs x,yPlot 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);

Page 7: 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 >>t=linspace(0,2*pi,100);

ExercisePlot 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