Ask MATLAB Expert

The tank in the water tower has the geometry shown in figure below (the lower part is a cylinder and the upper part is an inverted frustum cone).  Inside the tank there is a float that indicates the level of the water.
 You will be writing a function that determines the volume of the water in the tank from the position (height h) of the float.  This function will be called cs151sp13assn7 and there will be one input argument to the function that represents the height of the water in meters (this value could come in as a matrix of multiple water values).  There are no output variables for this function.

NOTE: You may be using if statements, the find function and the any function to help you with the steps outlined below.  There may be a combination of these commands or you may have a different way to solve it.  However, you may NOT use any loop commands to solve the problem.

1037_loop comand.png

A Step-by-step Procedure

1.  Create the correct function header as defined above.

2.  Check to see if there are any heights within the matrix that will cause the water to overflow the tank or if there are any values that are negative.  In either of these cases, your function should display an error message and stop processing.

3.  Find all the heights that are less than or equal to 24 meters.

4.  Print out how many values meet the criteria in step 3.

5.  If there are any values less than or equal to 24 meters, then find out the volume of these water levels using the equation: v = Π (14.5)2h.

6.  Print out these values using the fprintf command (see the ex below for what the output will look like – note that the height and volume values are printed out to two decimal places).

7.  Redo steps 3 through 6 for heights that are greater than 24 meters and use the volume equation: v = Π (14.5)2 (24) + 1/3 Π (h – 24) (14.52 + 14.5rh+rh2) where rh = 14.5 + 11.5/21 (h – 24).

ex Output

>> cs151sp13assn7([24 25 26 27 23 22 28 0 1])
There are 5 values below (and including) 24
For h = 24.00 m, the volume is 15852.48 m^3
For h = 23.00 m, the volume is 15191.96 m^3
For h = 22.00 m, the volume is 14531.44 m^3
For h = 0.00 m, the volume is 0.00 m^3
For h = 1.00 m, the volume is 660.52 m^3
There are 4 values above 24
For h = 25.00 m, the volume is 16538.26 m^3
For h = 26.00 m, the volume is 17275.81 m^3
For h = 27.00 m, the volume is 18067.03 m^3
For h = 28.00 m, the volume is 18913.79 m^3
>> cs151sp13assn7([25 26 27 28])
There are 0 values below (and including) 24
There are 4 values above 24
For h = 25.00 m, the volume is 16538.26 m^3
For h = 26.00 m, the volume is 17275.81 m^3
For h = 27.00 m, the volume is 18067.03 m^3
For h = 28.00 m, the volume is 18913.79 m^3
>> cs151sp13assn7([24 46 26 27 23 22 28 0 1])
Invalid values are in the matrix, please rerun function with valid values
>> cs151sp13assn7([45 24 0])
There are 2 values below (and including) 24
For h = 24.00 m, the volume is 15852.48 m^3
For h = 0.00 m, the volume is 0.00 m^3
There are 1 values above 24
For h = 45.00 m, the volume is 43632.79 m^3
>> cs151sp13assn7([45 -2 0])
Invalid values are in the matrix, please rerun function with valid values

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M9407
  • Price:- $65

Guranteed 36 Hours Delivery, In Price:- $65

Have any Question? 


Related Questions in MATLAB

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignment -we have daily gridded rainfall data of 40 years

Assignment - We have daily gridded rainfall data of 40 years and structure of the dataset is like below; Lat = [6.5:0.25:38.5]; Lon = [66.5:0.25:100]; Rainfall (135x129x365x40) (Lon, Lat, days, years). Now, we looking fo ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

What comparison of means test was used to answer the

What comparison of means test was used to answer the question

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As