Question: The figure below shows an object with a cylindrical tank in the middle with hemispherical (half of a sphere) caps on each end; similar to
The figure below shows an object with a cylindrical tank in the middle with hemispherical (half of a sphere) caps on each end; similar to a pill. The total height of the object is H and has a radius r for the hemispherical caps and the central cylinder. If the height of the liquid is h, what is the volume of the liquid in the tank? Note that the height of the cylinder is H - 2r. The calculation of the volume of liquid in the object depends upon the relationship between h, H and r. If h sr, we need the volume v of a partially filled hemisphere given by: If h >r but s H -r, we need the volume of a fully filled hemisphere plus the volume of a cylinder of height h -r 2 If h> H -r, we need the volume of a fully filled sphere (this takes into account the hemisphere on the bottom and the top) plus the volume of a cylinder of height H-2r minus the partially empty upper hemisphere of height H-h: 4 Write a MATLAB function that has three input arguments (h, H and r) to calculate the liquid level(s). The function should print (using fprintf) H and r on one line followed by h and the corresponding liquid level rounding all the values to 8 decimal places. The function should check for invalid values such as negative numbers and values that mean that the liquid is too high for the object. It will stop processing if there are an invalid values for h. NOTE: h could be a matrix of values that may have heights in any of the conditions listed above. For an extra 15 points, have the function return the volume in the same corresponding order as the height values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
