rotateBodies

# rotateBodies - %determines the number of columns needed to...

This preview shows pages 1–2. Sign up to view the full content.

function rotateBodies(u,v,th) %Given three vectors x, z, and theta, write a function rotateBodies that %will generate three plots. Your function should plot the three plots %in the same figure by using the subplot command. The figure should %have 1x3 plots. The plots should be as follows: %1. z vs. x; titled 'z vs. x'. Note that you will have to use %plot3() to correctly plot this in the xz plane rather than the xy %plane as plot() would do. Also, you should use view(0, 0) to make %the plot produced by plot3() show up as 2D as shown in the example %image. %2. z vs. x rotated around the x axis using mesh() with flat shading %and a square axis; titled 'z vs. x about x using mesh'. Turn on %the background grid. %3. z vs. x rotated around the z axis using surf() with interp %shading and a square axis; titled 'z vs. x about z using surf'. %Turn on the background grid. %usage: rotateBodies(u,v,th); subplot(1,3,1); %makes a 1 by 3 subplot with position 1 cols = length(u);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %determines the number of columns needed to create the y data y = zeros(1,cols); %creates 1 row of columns of zeros plot3(u,y,v); %plots the u, y, and v data view(0,0); title('z vs. x'); %titles the plot xlabel('x-axis'); %labels the x-axis zlabel('z-axis'); subplot(1,3,2); %makes a 1 by 3 subplot with position 2 [uu tth] = meshgrid(u,th); [vv tth] = meshgrid(v,th); rr = vv; xx = uu; yy = rr.*sin(tth); zz = rr.*cos(tth); mesh(xx,yy,zz); axis square; shading flat; grid on; title('z vs. x about x using mesh'); %titles the plot xlabel('x-axis'); zlabel('z-axis'); ylabel('y-axis'); subplot(1,3,3); %makes a 1 by 3 subplot with position 3 [uu tth] = meshgrid(u,th); [vv tth] = meshgrid(v,th); rr = uu; xx = rr.*sin(tth); zz = vv; yy = rr.*cos(tth); surf(xx,yy,zz); shading interp; axis square; title('z vs. x about z using surf'); %titles the plot grid on; xlabel('x-axis'); zlabel('z-axis'); ylabel('y-axis'); end...
View Full Document

## rotateBodies - %determines the number of columns needed to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online