Calculating Volume Levels of a Cylindrical Tank

In summary, there is a need to create a function that will supply a vector with the heights at which markers should be placed on a tank to display the volume at that level. The equation for the volumes being used is provided and the attempt at a solution involves using a for loop and the solve function. However, there may be some issues with the for loop and the use of the solve function that should be double checked.
  • #1
RollDozer
1
0

Homework Statement


I need to create a function that will supply me with a vector that lists the heights at which markers should be placed on a tank to display the volume at that level. The tank is a cylinder on its side with 2 boxes on either end to make it free standing (image attached).

I've got my code to give me an answer for the first V input, but it does not provide answers for the other V's.

Homework Equations


This is the equation for the volumes that I am using:

Vend = (2/5)*R*h*L
Vcyl = (R^2*L*acos((R-h)/R) - L*sqrt(2*R*h-h^2)*(R-h))

Vtotal = Vend + Vcyl - V_Scales, where V_Scales is the volume levels at which heights are desired.

The Attempt at a Solution


Code:
syms h
x = length(V_Scales);
%vmax=pi*(R^2)*L+(4/5)*(R^2)*L;

Vcyl = (R^2*L*acos((R-h)/R) - L*sqrt(2*R*h-h^2)*(R-h));
Vend = (2/5)*R*h*L;

h_found = zeros(x,1);

for i=1:length(x)
    Vtotal = Vend + Vcyl - V_Scales(i);
    h_found(i) = solve(Vtotal);
end

yScales = double(h_found);

end
I'm just looking for a hint or tip to help get this function to spit out the number of values that I ask for.

Thanks!EDIT: I little bit of double checking my code would have saved me a load of time. The beginning of the for loop should read: for i = 1:x, since I already defined the length of the input vector as x and when I was redoing code I just left it the same as I started.
 

Attachments

  • Cylinder Pic.pdf
    24.9 KB · Views: 210
Last edited:
Physics news on Phys.org
  • #2


Hi there,

It seems like you are on the right track with your code. One suggestion I have is to double check your for loop. In the code you provided, you have "for i=1:length(x)", which may be causing an issue. The "length" function is typically used to find the length of a vector or array, so using it on a single value (in this case, x) may not give you the desired result. Instead, try using "for i=1:x" to iterate through the values in your input vector.

Another suggestion is to double check your use of the "solve" function. This function typically takes in an equation and a variable to solve for, so using it in the way you have might not give you the desired result. Instead, try setting up your equation and then solving for the variable "h" using the "solve" function.

I hope these tips help you get your function to work for multiple input values. Good luck!
 

1. How do you calculate the volume of a cylindrical tank?

The volume of a cylindrical tank can be calculated using the formula V = πr2h, where V is the volume, r is the radius of the base, and h is the height of the tank.

2. What units should be used for the measurements when calculating the volume of a cylindrical tank?

The units used for the measurements should be consistent. For example, if the radius is measured in meters, then the height should also be measured in meters. This will ensure that the final volume is in cubic meters.

3. Can the volume of a partially filled cylindrical tank be calculated?

Yes, the volume of a partially filled cylindrical tank can be calculated by multiplying the cross-sectional area of the liquid by the height of the liquid. The cross-sectional area can be calculated using the formula A = πr2, where A is the cross-sectional area and r is the radius of the tank.

4. How do you convert the volume of a cylindrical tank to different units?

To convert the volume of a cylindrical tank to different units, you can use unit conversion factors. For example, to convert from cubic meters to cubic feet, you would multiply the volume in cubic meters by 35.3147.

5. Are there any other factors that should be considered when calculating the volume of a cylindrical tank?

Yes, the temperature and pressure of the liquid inside the tank can affect the volume. The volume may also change if the tank is not perfectly cylindrical or has uneven sides. It is important to measure and account for these factors when calculating the volume.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
31
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
914
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • General Math
Replies
3
Views
2K
Replies
50
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top