hw03_problem4

hw03_problem4 - disp('The lengths (inches) are:')...

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

% ENGR 12600 Fall 2008 % Solution to Homework 3, Problem 4. % This program calculates the maximum enclosed volume of a package shipped by UPS given a vector of lengths. % It also plots the volume as a function of length. % The students generate the code from a flowchart provided. % ---- Input Section ---- % Step 1 inputs the maximum package size (length + girth) max_size = 165; % (inches) % Step 2 creates a vector with specified lengths ranging from 35 to 105 inches in 10 inch increments length = [35:10:105]; % (inches) % alternate: length = [35 45 55 65 75 85 95 105] % ---- Calculation Section ---- % Step 3 calculates a vector of the maximum dimension of a side assuming a square cross-section (inches) side = (max_size - length)./4; % Step 4 calculates a vector of volumes (cubic inches) volume = (length.*side.^2); % ---- Output Section ---- % Step 5 displays the vectors for the length, side, and volume
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: disp('The lengths (inches) are:') disp(length) disp('The maximum dimensions of a side (inches) are:') disp(side) disp('The calculated volumes (cu in) are:') disp(volume) % Step 6 plots the volume as a function of package length plot(length,volume) % Formats the graph according to proper plotting format title('Maximum volume of a UPS package as a function of its length') ylabel('Maximum package volume for this length (cu in)') xlabel('Length of package being shipped (in)') %----Final Tabulated Results----% Length Side Volume % (inches) (inches) (inches^3) % 35 36.25 3.6969*1.0e+004 % 45 31.25 4.0500*1.0e+004 % 55 26.25 4.1594*1.0e+004 % 65 21.25 4.0625*1.0e+004 % 75 16.25 3.7969*1.0e+004 % 85 36.25 3.4000*1.0e+004 % 95 31.25 2.9094*1.0e+004 % 105 26.25 2.3625*1.0e+004...
View Full 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.

Ask a homework question - tutors are online