# Matlab Problem

## 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

• 24.9 KB Views: 107
Last edited:

## Answers and Replies

Related Engineering and Comp Sci Homework Help News on Phys.org