hw03_problem5 - % ENGR 12600 Fall 2008 % Solution to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
% ENGR 12600 Fall 2008 % Solution to Homework 3, Problem 5. % This program calculates the upper and lower bounds of the number of steel balls that will fit into a cube ranging between 0.5 and 3.5 meters per side. % The students generate the code from a flowchart provided. % ---- Input Section ---- % Step 1 assigns the diameter of the steel sphere diameter = .015; % (meters) % Step 2 creates a vector with specified lengths of each side of a cube ranging from 0.5 to 3.5 m in 0.5 m increments box_dimension = [0.5:0.5:3.5]; % alternate: length = [0.5 1.0 1.5 2.0 2.5 3.0 3.5] % ---- Calculation Section ---- % Step 3 calculates a vector of volumes of each box (m^3) box_volume = box_dimension.^3; % Step 4 calculates the volume of a sphere (m^3) sphere_volume = (4/3)*pi*(diameter/2)^3; % alternate: sphere_volume = (1/6)*pi*diameter^3; % Step 5 calculates the upper bound of the number of steel spheres that % fit in each box. upper_bound = floor(box_volume/sphere_volume);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/12/2012 for the course ENGR 126 taught by Professor Oakes during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 2

hw03_problem5 - % ENGR 12600 Fall 2008 % Solution to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online