How to use the "Input" command-- specific problem help

1 view (last 30 days)
I don't understand how to do the input command.. can someone help me?
The figure attached shows a cylindrical tank of height H and radius r, with a spherical cap on each end (also of radius r). The height of the liquid in the tank is h. Use the input command to obtain values for H, r & h and compute the volume of liquid in the tank.
The calculation of the volume of liquid in the tank depends upon the relationship between h, H and r:
• If h is less than r, we need the volume of a partially-filled sphere
• If h is greater than r but less than H-r, we need the volume of a fully- filed hemisphere plus the volume of a cylinder of height h-r
• If h is greater than H-r, we need the volume of a fully-filled sphere, plus the volume of a cylinder of height H-2r, minus the partially empty upper hemisphere of height H-h
• If h is greater than H, the function should generate an error message (using error)

Answers (1)

Amit
Amit on 2 Feb 2014
The input command ask for a value from the user, for example
A = input('Enter value for h: ')
will show on command prompt:
Enter value for h:
Where the user will provide the value and that value will be store in the variable, here A.
For more about input, type on command prompt
help input

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!