Question

Needs to be solved by a script in MATLAB. Use of if, else, and ifelse statements are encouraged. My main issue is figuring out what order to place if statements in. Please comment if any more info is needed

Create a script file which prompts the user for the water level of the tank pictured below. The tank has a cylindrical base w

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find required MATLAB code along with necessary details in comments:

H1=25;
H2=25;
D=40;

r=D/2;

depth=input('Enter the height of water in the tank:');

if depth<=0
fprintf('Negative depths are not possible. ');
Volume=[];
  
elseif (depth<=H1)
Volume=pi*r*r*depth;
fprintf('There is %3.4f ft^3 waterin the tank.\n ',Volume);
  
elseif (depth>H1) & (depth<=H1+H2)
Volume=(pi*r*r*H1)+ (((1/3)*pi*r*r*(depth-H1)));
fprintf('There is %3.4f ft^3 waterin the tank.\n ',Volume);
  
else
fprintf('ERROR: You entered a height which is greater than the height of the tank, which is not possible.\n')
end

=========================== SCREENSHOT OF CODE

TankVolume.m X H1-25; 2H2-25: D-40 r-D/2: depth-input (Enter the height of water in the tank: -if depth<=0 10 fprintf ( Neg

========================================= SAMPLE OUTPUT

Command Window >>TankVolume Enter the height of water in the tank: 15 There is 18849.5559 ft 3 waterin the tank. 7 TankVolume

Add a comment
Know the answer?
Add Answer to:
Create a script file which prompts the user for the water level of the tank pictured below. The t...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT