Question: MATLAB Lab 4 ( Function ) Note: For all labs and assignments copy and paste into a Word file your program ( script file )

MATLAB Lab 4(Function)
Note: For all labs and assignments copy and paste into a Word file your program (script
file), the relevant command window and plots if applicable. Try to condense the print-out
as best as possible.
Objective
Introduction to user defined functions in MATLAB.
Procedures
The objective of this exercise is to minimize the total surface area of a cylindrical metal can for a
given volume and compare that area to that of a sphere of equal volume. Assume that the volume
is equal to ~~3.1416.
For this exercise, first create two user function files:
cylinder.m Inputs - radius, height Outputs - volume, area
sphere.m Input - radius Outputs - volume, area
Next create a MATLAB program (script .m file) to perform the following steps:
For cylinder:
(1) Display table headings for cylinder radius, height, volume and area
(2) For radius values of 0.5 to 1 in steps of 0.05
Compute the height resulting in constant volume
Call cylinder.m to calculate and return cylinder volume and area
Display the results formatted to 4 significant figures
Find and display the minimum cylinder area and corresponding radius and height.
For sphere:
(3) Calculate and display the sphere radius for a volume of .
(4) Call sphere.m to calculate, return and display sphere volume and area.
Finally, compare the minimum cylinder area to the sphere's area.
A program template ENGR1204_Lab4_template.m is shown below and can be downloaded
from WebCampus.
Formulas
Cylinder: volume =r2h, area =2rh+r2+r2=2r(r+h)
(sides)(top)(bottom)
Sphere: , volume =(43)r3, area =4r2
MATLAB Lab 4 ( Function ) Note: For all labs and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!