6.2: A Modeling Example: Counting Ping Pong Balls
Suppose you have a cylinder of height \begin{align*}h\end{align*}
A lower bound for this problem is found as follows. Define the following variables:

\begin{align*}N_L\end{align*}
NL− Lower bound on the number of balls that fit into the cylinder. 
\begin{align*}V_{cyl}\end{align*}
Vcyl− The volume of the cylinder.  \begin{align*}V_{cube}\end{align*}The volume of a cube that encloses a single ball.
\begin{align*}V_{cyl} & = h\pi(\tfrac{b}{2})^2 \\ V_{cube} & = d^3\end{align*}
The lower bound \begin{align*}N_L\end{align*} is found by dividing the volume of the cylinder by the volume of the cube enclosing a single ball:
\begin{align*}N_L = \tfrac{V_{cyl}}{V_{cube}}\end{align*}
Exercise 11
You are given the following values:
 \begin{align*}d = 1.54\;\mathrm{in}\end{align*}
 \begin{align*}b = 8\;\mathrm{in}\end{align*}
 \begin{align*}h = 14 \;\mathrm{in}\end{align*}
Type commands at the command line prompt to compute \begin{align*}N_L\end{align*}.
Exercise 12
Create an mfile to solve Exercise 11.
To complicate your problem, suppose that you have not been given values for \begin{align*}d\end{align*}, \begin{align*}b\end{align*}, and \begin{align*}h\end{align*}. Instead you are required to estimate the number of ping pong balls for many different possible combinations of these variables (perhaps \begin{align*}50\end{align*} or more combinations). How can you automate this computation?
One way to automate the computation of \begin{align*}N_L\end{align*} for many different combinations of parameter values is to use a for loop. The following exercises ask you to develop several different ways that for loops can be used to automate these computations.
Exercise 13
Add a for loop to your mfile from Exercise 12 to compute \begin{align*}N_L\end{align*} for \begin{align*}b = 8 \;\mathrm{in}\end{align*}, \begin{align*}h = 14 \;\mathrm{in}\end{align*}, and values of \begin{align*}d\end{align*} ranging from \begin{align*}1.0 \;\mathrm{in}\end{align*} to \begin{align*}2.0 \;\mathrm{in}\end{align*}.
Exercise 14
Modify your mfile from Exercise 13 to plot \begin{align*}N_L\end{align*} as a function of \begin{align*}d\end{align*} for \begin{align*}b = 8 \;\mathrm{in}\end{align*} and \begin{align*}h = 14 \;\mathrm{in}\end{align*}.
Exercise 15
Modify your mfile from Exercise 13 to compute \begin{align*}N_L\end{align*} for \begin{align*}d = 1.54 \;\mathrm{in}\end{align*} and various values of \begin{align*}b\end{align*} and \begin{align*}h\end{align*}.