Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem # 3 A cylindrical, vertical water tank has hemispheric end caps as shown. The radius of the cylinder and the caps is r =

Problem #3
A cylindrical, vertical water tank has hemispheric end caps as shown. The radius of the cylinder and the caps is r=40cm, and the length of the cylindrical part is 1.2m.
Hint:
For a hemispherical "concave up" bowl of radius R, the volume of water contained in it at a water level height y is:
V=3y2(3R-y)
You are interested in developing a program to find the volume of water contained in the tank at a given height h.
Required Tasks
Write a MATLAB function named calculate_volume that fulfills these specs:
Accepts the radius r(in m), cylinder height (in m), and the height h(in m) as input arguments.
Calculates the volume of water inside the tank if the water level is h.
Hint: Think of the tank as three distinct regions, each with its own set of volume equations.
While you could put all of the selection and calculation code within calculate_volume, consider writing additional functions to make your program more modular or efficient.
Returns the computed volume as the output argument.
Create a MATLAB script that tests your function. The specifications are:
Within a loop:
Displays a menu of which allow the user to select from these options: enter a single h value, or plot a graph of volume versus height h, or quit the program.
If requested, calls your calculate_volume function to do the actual calculation and then displays the result.
If the user wants a plot, then it should be generated like this:
Plots water volume versus height h, where h goes from 0m to the full height of the tank.
Has reasonable axes labels and a title.
Do NOT use element-by-element operators for this problem. Instead, use a for loop to create the vectors needed to make the plot.
Save your script file using this file name: hw4x3.m
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions