I.1 INTRODUCTION TO EXCEL Spreadsheets, such as Excel, have ceased to be strictly business applications and professionals from many disciplines have found uses for this simple, yet powerful approach to performing mathematical calculations. Engineers were quick to start using electronic spreadsheets for design calculations because of the automatic recalculation feature. Automatic recalculation allows a designer to change a variable and quickly see how that change impacts the r est of the design. Over the years, spreadsheet programs have become more powerful and faster, allowing even larger problems to be solved. Excel is easy to learn, and many people can start to use Excel to perform simple calculations in minutes. After learning just a few basics, most Excel users can solve a wide r ange of problems quickly and efficiently. The extra power available from Excel's built-in functions, graphics capabilities, and r egression options can be learned as needs arise. And, if needed, Excel even provides a built-in programm ing environment that allows you to extend the capabilities of the program to meet specific needs. In the examples and case studies that accompany this text, all of these features will be used. Excel BasicsWhen you start the Excel program, you will see a window that is mostly an open grid, as shown in Figure I.1. Figure I.1. The Excel user interface. Each rectangle in the grid is called a cell, and can be identified by a column letter and a row number. In Figure I.1 cell A1 is shown with a dark border. The dark border indicates that cell A1 is the active cell. Ifyou start typing, the characters will always be entered into the active cell. A cell can contain one of three things:
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
I.1 INTRODUCTION TO EXCELSpreadsheets, such as Excel, have ceased to be strictly business applications and professionals from many
disciplines have found uses for this simple, yet powerful approach to performing mathematicalcalculations. Engineers were quick to start using electronic spreadsheets for design calculations because
of the automatic recalculation feature. Automatic recalculation allows a designer to change a variable andquickly see how that change impacts the rest of the design. Over the years, spreadsheet programs have
become more powerful and faster, allowing even larger problems to be solved.
Excel is easy to learn, and many people can start to use Excel to perform simple calculations in minutes.After learning just a few basics, most Excel users can solve a wide range of problems quickly andefficiently. The extra power available from Excel's built-in functions, graphics capabilities, and regressionoptions can be learned as needs arise. And, if needed, Excel even provides a built-in programmingenvironment that allows you to extend the capabilities of the program to meet specific needs. In the
examples and case studies that accompany this text, all of these features will be used.
Excel Basics
When you start the Excel program, you will see a window that is mostly an open grid, as shown in FigureI.1.
Figure I.1. The Excel user interface.
Each rectangle in the grid is called a cell , and can be identified by a column letter and a row number. InFigure I.1 cell A1 is shown with a dark border. The dark border indicates that cell A1 is the active cell . If you start typing, the characters will always be entered into the active cell.
Excel analyzes the characters you enter into a cell to try to automatically determine which of the three you
have entered.• If you enter a numeric value (characters 0 – 9, and minus sign), Excel will recognize the number
and display the entry as a number (right justified, general format).
• If you start your cell entry with an equal sign, Excel will interpret your cell entry as an equation
(called a formula in Excel) and attempt to mathematically evaluate the formula and display theresult in the cell.
• If Excel cannot recognize your cell entry as either a number or formula, then it displays the entry
as text (left justified, general format).
When you enter a formula into a cell, the formula is stored in the cell, but the result of the calculation isdisplayed. By storing the formulas, Excel can automatically recalculate all of the equations in the
worksheet whenever any value is changed. But, by hiding the equations used to calculate the displayedvalues, it can be difficult to follow the sequence of calculations that leads to a particular result, and evenharder to find errors. In the Excel examples in this text, the equations used to calculate values are shownto the right of the displayed result. Most calculations are presented in the following format.
| variable name | displayed value | units | formulas used | note reference |
The note reference is only used when needed.
Excel allows you to enter text and formulas in any cell. Behind the scenes, Excel keeps track of whichformulas depend on which cells, so that automatic recalculation of the formulas (in the correct order) is
possible. While Excel does not care where you put the formulas, your worksheets will be much easier to
read if you present the calculations in some logical manner. In the Excel examples in this text, thecalculation order is simply from the top of the worksheet down.
Excel does not handle units, so Excel users need to be careful to watch the units in their calculations and provide conversion factors as needed. In the examples included with this text, the units of each calculatedresult are displayed to the right of the result.
The best way to learn to use Excel is to start using it. The following examples are designed to illustratesome of the features that are useful when solving design problems. While each of these examples is
available on the disk that accompanies this text, you will learn Excel faster by trying these examplesyourself.
Solving Simple Models We wish to design a 1-liter capacity cooking pot, as shown in Figure I.2, to be made of 1-mm-thick stainless steel. Ultimately we would like to minimize the amount of stainless steel used. We will start withthe simplest possible model.
EXAMPLE I-1
Simple Equation-Solving Using Excel – Part A
Problem Find the height and empty weight of an open-top, cylindrical container (cooking pot)for a desired volume.
Given Volume 1 liter = 1000 cm3
Inside diameter 12 cm
Wall thickness 0.1 cm
Assumptions The material is stainless steel, mass density = 7.75 g/cm3.
Solution See Figure F-1, Tables F-1 and F-2, and Excel file Example1.xls.
1 The contained volume is the base area times the height. The base area can be calculated from the known
inside diameter. To calculate the base area, we first enter the diameter in a cell.
Figure I.3. Setting the diameter.
Notice that three cells were used to specify the diameter: cell B4 contains the variable name, cell C4 contains
the numeric value, and cell D4 contains the units. This pattern will be used extensively in these examples.
The base area can be calculated from the specified inside diameter.
2
4d Abase
π =
This formula is entered into cell C5, as shown in Figure I.4. Notice that the formula in the active cell is
displayed in the formula bar just above the cell grid, while the calculated result (113.0973 cm2) is shown in
cell addresses, they can still be hard to follow. In Part B of this example we will introduce named cells, which
can make the formulas easier to read.
Modifying Excel Worksheets to Solve Related Problems
Excel worksheets are easy to modify, which makes it possible to quickly adapt an existing solution whennecessary. In the next example, the worksheet is modified to solve for diameter instead of height.
EXAMPLE I-2
Simple Equation-Solving Using Excel – Part B
Problem Find the diameter and empty weight of an open-top, cylindrical container (cookingpot) for a desired volume.
Given Volume 1 liter = 1000 cm3
Inside height 10 cm
Wall thickness 0.1 cm
Assumptions The material is stainless steel, mass density = 7.75 g/cm3.
Solution See Figure F-1, Tables F-1 and F-2, and Excel file Example2.xls.
1 In this example we have specified the pot's height, and will calculate the diameter required to generate the
desired volume. We begin (unlike Part A) by entering all known quantities on the worksheet.
Figure I.11. Entering known values.
The Greek symbol ρ (rho) is a commonly used symbol for density. It was entered using the menu command
Insert / Symbol, then selecting ρ from the symbol dialog.
2 To make the formulas easier to read, we will use cell names in this example. To add a cell name:
1. Select the cell to be named (for example, cell C4 containing the known height).
2. Click on the name box at the left side of the formula bar. The name box is indicated in Figure I.12.
3. Enter the desired name for the cell. In this case, cell C4 has been named H since it contains the
Figure I.14. Determining the required diameter using named cells.
5 The rest of the solution is similar to Part A.
1. Calculate the surface area using A base, d and H.
2. Calculate the metal volume using Asurface and the metal thickness.
3. Calculate the mass using the metal volume and density.
Figure I.15. The completed solution.
Using Iteration and Root Finding We now complicate the problem by adding a height-to-diameter ratio constraint (H/D). The diameter required to generate the correct volume and maintain the desired height to diameter ratio can bedetermined using an iterative solution. Excel comes with a powerful Add-In, called the Solver, that is
designed to handle iterative solutions.
Before starting the next example, you may need to see if the Solver is available in your installation of
Excel. First, check to see if the Solver is included in the list of available Add-Ins:
Use menu command Tools / Add-Ins… to open the Add-Ins dialog to see the list of available Add-Ins.
If Solver Add-In appears in the list, make sure its box is checked and the Solver will be available for your
use.
If Solver Add-In does not appear in the list, it was not installed when Excel was installed. The onlysolution is to use the Excel installation CD to install the Solver. Then activate the Solver Add-In from theAdd-Ins dialog.
The use of the Solver for iterative solutions will be presented in the next example.
EXAMPLE I-3
Iterative Equation-Solving Using Excel's Solver – Part A
Problem Find the diameter, height and weight of an open-top, cylindrical container (cookingpot) for a desired volume and height/diameter ratio (H/D).
Given Volume 1 liter = 1000 cm3
H/D 0.6
Wall thickness 0.1 cm
Assumptions The material is stainless steel, mass density = 7.75 g/cm3.
Solution See Figure F-1, Tables F-1 and F-2, and Excel file Example3.xls.
1 There are a variety of ways to solve this problem in Excel, both with and without using the Solver. We
choose to demonstrate an iterative approach using the Solver, and begin by incorporating the H/D ratio into
7 At this point, the remaining unknowns are easily determined.
Figure I.23. The final solution.
In Example 3, Part A the H/D ratio was incorporated into the equation for volume to eliminate H andobtain a volume equation that depended only on D. This is not necessary because the Solver can handlemultiple change cells, and constraints. In Part B we will use the Solver to find both D and H, subject tothe H/D ratio constraint.
EXAMPLE I-4
Iterative Equation-Solving Using Excel's Solver – Part B
Problem Find the diameter, height and weight of an open-top, cylindrical container (cooking
pot) for a desired volume and height/diameter ratio (H/D).Given Volume 1 liter = 1000 cm
3
H/D 0.6
Wall thickness 0.1 cm
Assumptions The material is stainless steel, mass density = 7.75 g/cm3.
Solution See Figure F-1, Tables F-1 and F-2, and Excel file Example4.xls.
1 As usual, we begin by entering the known values. This time, the desired volume (1000 cm3) and the H/D
ratio are not included in the worksheet because these values will be entered directly into the Solver dialog.
Figure I.24. First, we enter the known values.
2 Next, we provide initial guesses for D and H. Since the cells containing these guesses will (after using the
Solver) contain the correct values, we will go ahead and name the cells D and H.
Arrays and Plotting in Excel The next example illustrates how a function can be evaluated for a range of values to create a data set for plotting.
This approach can be very useful for visualizing the values that a function returns, and is a simple way to find a
maximum or minimum value. In the following example, we will use a plot to find the height-to-diameter ratio that
minimizes the weight of the cooking pot.
EXAMPLE I-5
Arrays and Plotting in Excel
Problem Find the height/diameter ratio and dimensions of an open-top, cylindrical containerthat will minimize its weight for a given volume. Plot the variation of weight with theheight/diameter ratio.
Given Volume 1 liter = 1000 cm3
Wall thickness 0.1 cm
Assumptions The material is stainless steel, mass density = 7.75 g/cm3. The ratio H/D will be
varied between 0.1 and 2.0.
Solution See Figure F-1, Tables F-1 and F-2, and Excel file Example5.xls.
1 We begin by defining the given and assumed values.
Figure I.32. The known values are entered.
2 Next, create a column of H/D ratio values ranging from 0.1 to 2.0.
Figure I.44. The plot of metal weight as a function of H/D ratio.
9 The minimum metal weight appears to occur at an H/D ratio very near 0.5.
Using Built-In Functions There are other ways to find the minimum metal weight using Excel. In the next example (Example 6) wewill determine the minimum metal mass directly from the array values using Excel's min() function.Then, in Example 7, we will demonstrate using the Solver to find the minimum weight without usingarrays at all.
EXAMPLE I-6
Using Array Functions in Excel
Problem Find the height/diameter ratio and dimensions of an open-top, cylindrical containerthat will minimize its weight for a given volume. Plot the variation of weight with theheight/diameter ratio.
Given Volume 1 liter = 1000 cm3
Wall thickness 0.1 cm
Assumptions The material is stainless steel, mass density = 7.75 g/cm3. The ratio H/D will be
varied between 0.1 and 2.0.Solution See Figure F-1, Tables F-1 and F-2, and Excel file Example6.xls.
1 We first create the HDratio, D, H, Vm, and W arrays. The process was described in steps 1 through 6 of the
previous Example. The only change is that the arrays are a bit larger because a smaller increment was used to
define the range of HDratio values. This was done to get a slightly more precise result.
Figure I.50. The optimal solution returned by the Solver.
User-Defined Functions Excel comes with hundreds of built-in functions, but there are times when it is helpful to create a new
function for a specific purpose. Excel provides a built-in programming capability to allow you to writeyour own functions. Once the functions are written, they can be used from the worksheet like any other Excel function.
The programming language built into Excel and other Microsoft Office®
products is called Visual Basicfor Applications, or VBA. The Applications part of the name is a set of Visual Basic extensions that allow
Visual Basic to work with the data in a worksheet.
These few pages will not begin to teach you how to use VBA, but our goal here is simply to demonstrate
that it is possible, and provide an overview of the process of creating a user-written function.
A VBA function is stored with a workbook. This means that, in general, only the workbook in which thefunction was written will have access to the new function. To create a function from Excel you do the
following:
1. Start the Visual Basic Editor using menu commands Tools / Macro / Visual Basic Editor.
2. In the Project list, click on the list item entitled VBA Project ( your worksheet name) toselect it.
3. Insert a module using menu command Insert / Module.
4. Insert a function procedure into the module using Insert / Procedure menu commands.
5. Add your programming lines to the function.
6. Save the changes to the Visual Basic editor (File/Save) to save your function and make itavailable to the Excel worksheet.
7. Return to the Excel worksheet and use the function (just like a built-in function).In the following Example, we will create a function that receives a value for H/D and calculates thecorresponding metal weight for our problem.
Working with Arrays as Lists Automatically choosing data from an array can be handy (after getting the data into the computer). Excel
provides two look-up functions for this purpose: HLOOPUP() and VLOOKUP(). HLOOKUP() searches
across a row for the appropriate value, while VLOOKUP() searches down columns. The HLOOKUP()
function will be used in out next example.
In the next example, we use a look-up function to material property data in an array. The data will includea few properties for three metals (from Table C-1).
Example I-9
Selecting Data from Arrays in Excel
Problem Use a look-up function to return the material properties of a selected material from anarray.
Given Material properties from Table C-1
Property Aluminum Steel Copper
Density 2.8 7.8 8.9 g/cm3
Modulus of Elasticity 71.7 206.8 120.7 GPa
Modulus of Rigidity 26.8 80.8 44.7 GPa
Solution See Excel file Example9.xls.
1 First, create the array that holds the material property data. In Figure I.58, the array has been named
MatProps.
Note: Naming the array is not required; you can simply use cell ranges in the look-up functions.
Figure I.61. HLOOKUP() will return a value even if an exact match is not found.
Solving Simultaneous Linear Equations The force and momentum balances that are integral parts if machine design often generate systems of
simultaneous linear equations. Matrix methods can be very effective in solving this type of problem, andExcel provides built-in functions for performing the matrix operations needed to solve simultaneous
linear equations.
For this example, we start with a simple set of four simultaneous linear equations.
1 x1 + 3 x2 + 5 x3 + 7 x4 = 1
2 x1 + 1 x2 + 3 x3 + 5 x4 = 3
1 x1 + 5 x2 + 9 x3 + 2 x4 = 5
3 x1 + 1 x2 + 4 x3 + 1 x4 = 7
The first step is to rewrite this set of equations in matrix form, as a coefficient matrix times an x vector, set equal to
a right-hand-side vector.
[C] [x] = [rhs]
The common method of solution is to invert the coefficient matrix and obtain the solution by multiplying [C] -1 and
[rhs].
[C] [x] = [rhs]
[C]-1 [C] [x] = [C]-1 [rhs]
but [C]-1 [C] = [I], the identity matrix.
[I] [x] = [C]-1 [rhs]
Since multiplication by the identity matrix does not change the result,
[x] = [C]-1 [rhs]
The matrix math operations necessary to solve simultaneous linear equations are matrix inversion andmatrix multiplication. Excel's functions MINVERSE() and MMULT() can be used.