ENGR1121 – Computing Applications in Mechanical Engineering
Lab 3D Plotting
Lab due: end of lab
Total points: 20
Labs are to be individual work. You may use MATLAB Marina, MATLAB’s help, and your notes. Lab work will be
graded during lab time and working results must be shown to the lab instructor by the end of the scheduled
lab time. All MATLAB programs and functions must be completed and submitted in accordance with the
Computing Assignment Format and the MATLAB Coding Style. Submit an electronic copy of your lab work to
the appropriate Dropbox Folder in GSU’s Folio by the end of lab. No hard copy needed unless specifically
requested by the instructor.
Grading
Each problem will be graded according to: program design (identifying inputs/givens, process, and outputs;
algorithm) and program style (program comments, variable names, proper formatted input and output
including units) 25%, and program correctness 75%.
Lab Work
1. (5 points) A robot with a 0.5 m arm can rotate about its base at 2 rpm. The robot arm can be lowered and
raised at a rate of 1200 per minute and robot hand can be extended at a rate of 5 m per minute. The x, y, z
coordinates of its hand for a specific path (rotating at 2 rpm while lowering and extending the hand at the
maximum rate) were determined to be:
2
=
x ( 0.5 + 5t ) sin π t cos ( 4π t ) ;
3
2
y ( 0.5 + 5t ) sin π t sin ( 4π t ) ;
=
3
z
=
2
( 0.5 + 5t ) cos π t
3
Where time t is in seconds. Generate a 3D parametric plot of the path of the robot hand for 0 ≤ t ≤ 6
seconds. Use an increment in the time vector that is small enough to give you a smooth curve.
2. (5 points) Write a MATLAB program that will create three plots in separate figure windows:
•
Generate a surface plot of f ( x, y ) =
( 2x
2
+ 3y2 ) ⋅ e
(
− 0.5 x 2 + 0.8 y 2
) for the range −4.0 ≤ x ≤ 4.0 and
−3.0 ≤ y ≤ 3.0 . This surface plot should not show the wire mesh and have interpolated shading. The
MATLAB statement shading interp; used after the plotting statement will suppress the wire
mesh and set the face shading to interpolated. Make sure to use an appropriate interval for x and y.
•
Generate a second surface plot of f ( x, y ) =
( 2x
2
+ 3y2 ) ⋅ e
(
− 0.5 x 2 + 0.8 y 2
) for the range −4.0 ≤ x ≤ 4.0 and
−3.0 ≤ y ≤ 3.0 . This surface plot should only show the wire mesh and should show hidden lines. The
•
MATLAB function mesh will generate a surface plot showing only the wire mesh and the statement
hidden off; used after the plotting statement will allow hidden lines to show.
Generate a third surface plot of f ( x, y ) =
−3.0 ≤ y ≤ 3.0 and a horizontal plane at
( 2x
2
+ 3y2 ) ⋅ e
(
− 0.5 x 2 + 0.8 y 2
) for the range −4.0 ≤ x ≤ 4.0 and
z = 0.2 on the same set of axes. This surface plot should also
not show the wire mesh and have interpolated shading and the horizontal plane should be colored
dark gray. Two 3D plots can be shown on the same axes by plotting the first function, using the
statement hold on; so subsequent graphing operations are added to the existing active graph, then
plotting the second function. A horizontal plane can be generated by creating a 2D array of all ones of
1
Instructor: Dr. Priya Goeser ENGR1121 – Computing Applications in Mechanical Engineering
the appropriate dimensions and scaling the values. The color of the plane can be set to dark gray by
specifying dark gray as the face color and no edge color for the plot of the horizontal plane, i.e. use
'FaceColor',[.4 .4 .4], 'EdgeColor', 'none' as additional arguments to the
plotting function.
3. (5 points) Write a MATLAB program that will generate a Mobius strip. The parametric equations describing
x
a Mobius strip are: =
( R + S cos ( θ ) ) cos (θ ) , =y ( R + S cos ( θ ) ) sin (θ ) and z = S sin (
1
2
1
2
1
2
θ ) . For
S ∈ [ − w, w] and θ ∈ [ 0, 2π ] where w is the half width of the strip (width from middle of strip to outside
edge) and R is the mid circle radius. The Mobius strip will have a single twist and will have a height of zero
(band with zero thickness).
To generate a Mobius strip you will need to generate a surface plot of x, y, and z where x, y, and z are
parametric functions of the mesh of S and theta.
You will want R to be at least four times greater than w.
Assume a w.
You may want to change some of the following from their defaults: axis limits, view, colormap, lighting,
material property, and shading. Note that lighting modifications can be better observed with the surfl
command.
4. (5 points) You just realized that February 14th has passed and you haven't gotten anything for your
Valentine. Since you are in a programming class, sending the lucky person a MATLAB coded heart would
seem like a cool and sincere thing to do. Make sure you follow each and every instruction carefully or your
heart would turn out broken.
• Create a new script called 'valentine.m'
• Create 2 variables, 'x' and 'y' with range (0 to 2pi, interval 0.05) and (0 to 1, interval 0.05)
respectively.
• Use the meshgrid function to generate the matrices xx and yy from x and y
• Define: c = [0.1 + 0.9 * (pi - abs( xx - pi ))/pi ] .* yy
• Define: aa = c .* cos(xx)
• Define: bb = c.* sin(xx)
• Define: zz = (-2)*aa.^3 + (3/2)*c.^2 + 0.5
• Plot zz against aa and bb.
• Voila! You are now all set to present your heart to your Valentine.
2
Instructor: Dr. Priya Goeser
Lab 3D Plotting
of 2
Report
Tell us what’s wrong with it:
Thanks, got it!
We will moderate it soon!
Struggling with your assignment and deadlines?
Let EduBirdie's experts assist you 24/7! Simply submit a form and tell us what you need help with.
Free up your schedule!
Our EduBirdie Experts Are Here for You 24/7! Just fill out a form and let us know how we can assist you.
Take 5 seconds to unlock
Enter your email below and get instant access to your document