- 158 Views
- Uploaded on
- Presentation posted in: General

3D plotting

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

3D 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))

- 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-’);

- 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

- Load the elevation.mat from Assignment3
- surf(map) plots the function map(i,j) vsj,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))

- Plot z=x^2+y^2 vsx,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);

- 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