# computeV - R1 = D1 2 R2 = D2 2 R if h< 0 || h> D2 ||...

This preview shows page 1. Sign up to view the full content.

function [V] = computeV (D1, L1, D2, L2, h) % computeV computes water tank volume % Inputs: D1 = diameter of smaller cylinder in m (<= D2) % L1 = length of smaller cyliner in m % D2 = diameter of larger cylinder in m % L2 = length of larger cylinder in m % h = height of water in m % Outputs: V = water volume in litres % % calculates the volume of a partially filled horizontal cylinder segVol = @(R, h, L ) . .. L * (R.^2 * acos((R - h)/R) - (R - h).*sqrt(2 * R * h - h.^2));
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: R1 = D1 / 2; R2 = D2 / 2; R if h < 0 || h > D2 || D1 > D2 error ('Unreasonable input values'); end e if h < R2 - R1 % small cylinder empty m3 = segVol (R2, h, L2); elseif h > R2 + R1 % small cylinder full m3 = segVol (R2, h, L2) + pi * R1 ^2 * L1; else % both cylinders partially full m3 = segVol (R2, h, L2) + segVol (R1, h - (R2 - R1), L1); end e V = 1000 * m3; V end...
View Full Document

## This note was uploaded on 10/18/2010 for the course SYSC 3600 taught by Professor Adsd during the Spring '10 term at Universidad Alfonso X El Sabio.

Ask a homework question - tutors are online