What Every Engineer Should Know About Excel - J. P. Holman (CRC, 2006)

April 28, 2017 | Author: Khai Huynh | Category: N/A
Share Embed Donate


Short Description

Download What Every Engineer Should Know About Excel - J. P. Holman (CRC, 2006)...

Description

What Every Engineer Should Know About

EXCEL

WEE_SeriesPage.qxd6

3/27/06

2:56 PM

Page 1

WHAT EVERY ENGINEER SHOULD KNOW A Series Series Editor*

Phillip A. Laplante Pennsylvania State University

1. What Every Engineer Should Know About Patents, William G. Konold, Bruce Tittel, Donald F. Frei, and David S. Stallard 2. What Every Engineer Should Know About Product Liability, James F. Thorpe and William H. Middendorf 3. What Every Engineer Should Know About Microcomputers: Hardware/Software Design, A Step-by-Step Example, William S. Bennett and Carl F. Evert, Jr. 4. What Every Engineer Should Know About Economic Decision Analysis, Dean S. Shupe 5. What Every Engineer Should Know About Human Resources Management, Desmond D. Martin and Richard L. Shell 6. What Every Engineer Should Know About Manufacturing Cost Estimating, Eric M. Malstrom 7. What Every Engineer Should Know About Inventing, William H. Middendorf 8. What Every Engineer Should Know About Technology Transfer and Innovation, Louis N. Mogavero and Robert S. Shane 9. What Every Engineer Should Know About Project Management, Arnold M. Ruskin and W. Eugene Estes 10. What Every Engineer Should Know About Computer-Aided Design and Computer-Aided Manufacturing: The CAD/CAM Revolution, John K. Krouse 11. What Every Engineer Should Know About Robots, Maurice I. Zeldman 12. What Every Engineer Should Know About Microcomputer Systems Design and Debugging, Bill Wray and Bill Crawford 13. What Every Engineer Should Know About Engineering Information Resources, Margaret T. Schenk and James K. Webster 14. What Every Engineer Should Know About Microcomputer Program Design, Keith R. Wehmeyer

*Founding Series Editor: William H. Middendorf

WEE_SeriesPage.qxd6

3/27/06

2:56 PM

Page 2

15. What Every Engineer Should Know About Computer Modeling and Simulation, Don M. Ingels 16. What Every Engineer Should Know About Engineering Workstations, Justin E. Harlow III 17. What Every Engineer Should Know About Practical CAD/CAM Applications, John Stark 18. What Every Engineer Should Know About Threaded Fasteners: Materials and Design, Alexander Blake 19. What Every Engineer Should Know About Data Communications, Carl Stephen Clifton 20. What Every Engineer Should Know About Material and Component Failure, Failure Analysis, and Litigation, Lawrence E. Murr 21. What Every Engineer Should Know About Corrosion, Philip Schweitzer 22. What Every Engineer Should Know About Lasers, D. C. Winburn 23. What Every Engineer Should Know About Finite Element Analysis, John R. Brauer 24. What Every Engineer Should Know About Patents: Second Edition, William G. Konold, Bruce Tittel, Donald F. Frei, and David S. Stallard 25. What Every Engineer Should Know About Electronic Communications Systems, L. R. McKay 26. What Every Engineer Should Know About Quality Control, Thomas Pyzdek 27. What Every Engineer Should Know About Microcomputers: Hardware/Software Design, A Step-by-Step Example. Second Edition, Revised and Expanded, William S. Bennett, Carl F. Evert, and Leslie C. Lander 28. What Every Engineer Should Know About Ceramics, Solomon Musikant 29. What Every Engineer Should Know About Developing Plastics Products, Bruce C. Wendle 30. What Every Engineer Should Know About Reliability and Risk Analysis, M. Modarres 31. What Every Engineer Should Know About Finite Element Analysis: Second Edition, Revised and Expanded, John R. Brauer 32. What Every Engineer Should Know About Accounting and Finance, Jae K. Shim and Norman Henteleff 33. What Every Engineer Should Know About Project Management: Second Edition, Revised and Expanded, Arnold M. Ruskin and W. Eugene Estes 34. What Every Engineer Should Know About Concurrent Engineering, Thomas A. Salomone 35. What Every Engineer Should Know About Ethics, Kenneth K. Humphreys

WEE_SeriesPage.qxd6

3/27/06

2:56 PM

Page 3

36. What Every Engineer Should Know About Risk Engineering and Management, John X. Wang and Marvin L. Roush 37. What Every Engineer Should Know About Decision Making Under Uncertainty, John X. Wang 38. What Every Engineer Should Know About Computational Techniques of Finite Element Analysis, Louis Komzsik 39. What Every Engineer Should Know About Excel, Jack P. Holman

ADDITIONAL VOLUMES IN PREPARATION

What Every Engineer Should Know About

EXCEL J. P. Holman Southern Methodist University

Boca Raton London New York

CRC is an imprint of the Taylor & Francis Group, an informa business

CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2006 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Version Date: 20110713 International Standard Book Number-13: 978-1-4200-0719-0 (eBook - PDF) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http:// www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com

7326_C000.fm Page 9 Wednesday, March 29, 2006 5:50 AM

About the Author

J.P. Holman received a Ph.D. in mechanical engineering from Oklahoma State University. After research experience at the Air Force Aerospace Research Laboratories, he joined the faculty of Southern Methodist University, Dallas, Texas. Dr. Holman has published over 30 papers in several areas of heat transfer and is the author of three widely used books: Heat Transfer (9th edition, 2002), Thermodynamics (4th edition, 1988), and Experimental Methods for Engineers (7th edition, 2000). These books have been translated into Spanish, Chinese, Japanese, Korean, Portuguese, Thai, and Indonesian and are distributed worldwide. A fellow of ASME, Dr. Holman is a recipient of the Worcester Reed Warner Gold Medal and the James Harry Potter Gold Medal from ASME for distinguished contributions to the permanent literature of engineering. He is also the recipient of the American Society for Engineering Education’s George Westinghouse and Ralph Coats Roe Awards for distinguished contributions to mechanical engineering education.

7326_C000.fm Page 10 Wednesday, March 29, 2006 5:50 AM

7326_C000.fm Page 11 Wednesday, March 29, 2006 5:50 AM

Preface

This collection of materials involving operations in Microsoft Excel is intended primarily for engineers, although many of the displays and topics will be of interest to other readers as well. The procedures have been generated somewhat randomly as individual segments, which were distributed to classes as the need arose. They do not take the place of the many excellent books on the subjects of numerical methods, statistics, engineering analysis, or the information that is available through the Help/Index features of the software packages. Some of the suggestions offered herein will be obvious to an experienced user of the software but much less apparent or even eye-opening to others. It is this latter group for whom the collection was assembled. Some of the materials were written for use in classes in engineering laboratory and heattransfer subjects, so several of the examples are tainted in the direction of these applications. Even so, topics such as solutions to simultaneous linear and nonlinear equations and uses of graphing techniques are pervasive and easily extended to other applications. The reader will notice that a basic familiarity with spreadsheets, the formats for entering equations, and a basic knowledge of graphs is assumed. A basic acquaintance with Microsoft Word is also expected, including simple editing operations. The Table of Contents furnishes a fairly straightforward guide for selecting topics from the book. It must be noted that the topics are presented as stand-alone items in many cases, which do not necessarily depend on previous sections. Where previous topics are relevant they are noted in that section. The reader will find that some topics are repeated — such as instructions for formatting graphs and charts — where it was judged beneficial. In Chapter 1 the convention employed for sequential sets of operations is noted along with the background expected of the reader. The user will find the suggested custom keyboard setup in Section 2.3 to be very useful for typing equations and math symbols. While possibly of infrequent use, the application of photo inserts is discussed in Section 2.9. Increased use of scanners and digital cameras may add to the utility of these sections. Most engineering graphs are of the x-y scatter variety, and the combination of the information presented at Section 3.3 and suggested default settings at Section 3.22 should be quite helpful in application of these graphs. Most people do not think of using Excel to generate line drawings. The discussion in Section 4.2 illustrates the relative simplicity of making such drawings and embedding them in Excel and Word documents. Section 4.3 and Section 4.5 illustrate methods for inserting and combining symbols, equations, and graphics in both Excel and Word. Chapter 5 presents methods for solving single or simultaneous sets of linear or nonlinear equations. Section 5.4 presents an iterative method that is particularly useful for solving linear nodal equations in applications with sparse coefficient matrices. Histograms, cumulative frequency distributions, and normal probability functions are discussed in Chapter 6 along with several regression methods. Three regression techniques are applied to an example that analyzes the performance of a commercial air-conditioning unit. Because financial analysis is frequently a part of engineering design, Chapter 7 presents an abbreviated view of the built-in Excel financial functions. Several examples of the use of these functions are also given. Optimization techniques are also a part of engineering design, so Chapter 8 gives a brief view of the use of the Solver feature of Excel for analyzing such problems.

7326_C000.fm Page 12 Wednesday, March 29, 2006 5:50 AM

Pivot tables are employed for arranging and categorizing small or large sets of data into different formats. In the presentation in Chapter 9, the approach has been to employ their use not only for rearranging tabular information but also for inserting calculated results of interest. This presentation then becomes a vehicle to supplement the creation of data tables and charts by other means. J.P. Holman

7326_C000.fm Page 13 Wednesday, March 29, 2006 5:50 AM

Contents

1 1.1 1.2 1.3

Introduction ..........................................................................................................1 Getting the Most from Excel ................................................................................................1 Conventions ............................................................................................................................2 Outline of Contents ...............................................................................................................3

2

Miscellaneous Operations in Excel and Word ..................................................5 Introduction.............................................................................................................................5 Print Screen or Screen Dump...............................................................................................5 Custom Keyboard Setup for Symbols in Word ................................................................7 Viewing or Printing Column and Row Headings and Gridlines in Excel...................8 Assorted Instructions.............................................................................................................8 Moving Objects in Small Increments (Nudging)............................................................10 Formatting Objects in Word, Including Wrapping ........................................................11 Formatting Objects in Excel ...............................................................................................11 Use of Photo-Editing Software in Word, Including Wrapping ....................................11 Copying Cell Formulas: Effect of Relative and Absolute Addresses..........................14 Copying Formulas by Dragging the Fill Handle ...........................................................15 Shortcut for Changing the Status of Cell Addresses .....................................................17 Switching and Copying Columns or Rows, and Changing Rows to Columns or Columns to Rows ..........................................................................................17 2.14 Built-In Functions in Excel .................................................................................................18 2.15 Creating Single-Variable Tables Using the DATA/TABLE Command .......................19 2.16 Creating Two-Variable Tables Using the DATA/TABLE Command ..........................21 Problems .........................................................................................................................................24 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13

3

Charts and Graphs .............................................................................................27 Introduction...........................................................................................................................27 Moving Dialog Windows....................................................................................................27 Excel Chart Wizard Window Showing Choice of x-y Scatter Charts .........................28 Selecting and Adding Data for x-y Scatter Charts .........................................................29 Changing and Adding Data for Charts Using the SOURCE DATA Command .......30 Adding Data to Charts Using the ADD DATA Command ..........................................30 Adding Trendlines and Correlation Equations to Scatter Charts................................31 Equation for R2 .....................................................................................................................31 Correlation of Experimental Data with Power Relation ...............................................32 Use of Logarithmic Scales ..................................................................................................34 Correlation with Exponential Functions ..........................................................................35 Use of Different Scatter Graphs for the Same Data .......................................................36 3.12.1 Observations.............................................................................................................41 3.13 Plot of a Function of Two Variables with Different Chart Types ................................41 3.13.1 Changes in Gap Width and Chart Depth on 3-D Displays..............................44 3.14 Plots of Two Variables with and without Separate Scales............................................44 3.15 Charts Used for Calculation Purposes or G&A Format................................................45 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12

7326_C000.fm Page 14 Wednesday, March 29, 2006 5:50 AM

3.15.1 G&A Chart ................................................................................................................48 3.16 Stretching Out a Chart from a Single Chart Page..........................................................48 3.17 Alternate Chart Sizing Procedure Using MS Word .......................................................49 3.18 Calculation and Graphing of Moving Averages.............................................................50 3.18.1 Standard Error..........................................................................................................54 3.19 Bar and Column Charts ......................................................................................................55 3.20 Chart Format and Cosmetics .............................................................................................56 3.21 Surface Charts.......................................................................................................................58 3.22 Suggested Scatter Graph Setting as Default Chart ........................................................59 3.23 An Exercise in 3-D Visualization.......................................................................................63 3.24 Editing Excel Charts Using Word .....................................................................................63 3.25 Editing Excel Tables Using Word ......................................................................................65 3.26 Alternate Procedure.............................................................................................................67 3.27 Editing Excel Charts Directly in Word by Using Grouping .........................................69 Problems .........................................................................................................................................72

4

Line Drawings and Embedded Objects in Excel ............................................77 Introduction...........................................................................................................................77 Constructing, Moving, and Inserting Straight Line Drawings ....................................77 4.2.1 Drawing Line Segments in Precise Angular Increments ..................................78 4.3 Inserting Items in Excel with Symbols, Subscripts, and Superscripts........................83 4.4 Inserting Equations or Symbols in Word Using Equation Editor ...............................85 4.5 Inserting Equations and Symbols in Excel Using Equation Editor.............................86 4.6 Construction of Line Drawings from Plotted Coordinates...........................................88 Problems .........................................................................................................................................92 4.1 4.2

5

Solution of Equations ........................................................................................93 Introduction...........................................................................................................................93 Solutions to Single Nonlinear Equations Using Goal Seek ..........................................93 Solutions to Single Nonlinear Equations Using Solver.................................................95 Iterative Solutions to Simultaneous Linear Equations ..................................................98 Solutions of Simultaneous Linear Equations Using Matrix Inversion .......................99 5.5.1 Error Messages.......................................................................................................103 5.6 Solutions of Simultaneous Nonlinear Equations Using Solver..................................103 5.7 Solver Results Dialog Box ................................................................................................110 5.8 Comparison of Methods for Solution of Simultaneous Linear Equations ................................................................................................................ 111 5.9 Copying Cell Equations for Repetitive Calculations ...................................................112 5.10 Creating and Running Macros.........................................................................................113 Problems .......................................................................................................................................118 5.1 5.2 5.3 5.4 5.5

6 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8

Other Operations .............................................................................................. 121 Introduction.........................................................................................................................121 Numerical Evaluation of Integrals..................................................................................121 Use of Logical IF Statement .............................................................................................125 Histograms and Cumulative Frequency Distributions ..............................................128 Normal Error Distributions ..............................................................................................132 Calculation of Uncertainty Propagation in Experimental Results.............................138 Fractional Uncertainties for Product Functions of Primary Variables ......................142 Multivariable Linear Regression .....................................................................................145

7326_C000.fm Page 15 Wednesday, March 29, 2006 5:50 AM

6.9 Multivariable Exponential Regression............................................................................150 Problems .......................................................................................................................................158

7

Financial Functions and Calculations ............................................................ 161 7.1 Introduction.........................................................................................................................161 7.2 Nomenclature .....................................................................................................................161 7.3 Compound Interest Formulas..........................................................................................162 7.4 Investment Accumulation with Increasing Annual Payments...................................168 7.5 Payout at Variable Rates from an Initial Investment...................................................168 Problems .......................................................................................................................................171

8 Optimization Problems .................................................................................... 175 8.1 Introduction.........................................................................................................................175 8.2 Graphical Examples of Linear and Nonlinear Optimization Problems ...................176 8.3 Solutions Using Solver ......................................................................................................179 8.4 Solver Answer Reports for Examples.............................................................................182 8.5 Nomenclature for Sensitivity Reports ............................................................................185 8.6 Nomenclature for Answer Reports .................................................................................186 8.7 Nomenclature for Limits Reports....................................................................................186 Problems .......................................................................................................................................186 9

Pivot Tables ....................................................................................................... 191 Introduction.........................................................................................................................191 Other Summary Functions for Data Fields ...................................................................204 Restrictions on Pivot Table Formulas .............................................................................207 9.3.1 Ordering of Data Fields and Resultant Graphs ...............................................208 9.4 Calculating and Charting Single or Multiple Functions f(x) vs. x Using Pivot Tables.............................................................................................212 9.5 Calculating and Plotting Functions of Two Variables .................................................216 9.5.1 Display of Formulas and Solve Order ...............................................................219 Problems .......................................................................................................................................220 9.1 9.2 9.3

References .................................................................................................................. 223 Index ........................................................................................................................... 225

7326_C000.fm Page 16 Wednesday, March 29, 2006 5:50 AM

7326_C001.fm Page 1 Tuesday, March 7, 2006 6:16 AM

1 Introduction

1.1

Getting the Most from Excel

Microsoft Excel is a deceptive software package in that it offers computation and graphics capabilities far beyond what one would expect in a spreadsheet tool and also because its capabilities remain unknown to many engineers and technical persons. This book is written for the person who is casually familiar with Excel but is unaware of its broad potential. Although a novice will find the material useful, it will be most attractive to those who have the following: 1. A basic knowledge of both Excel and Word, including procedures for entering equations in Excel, editing fundamentals, and some experience with creating graphs 2. A basic knowledge of differential and integral calculus 3. For some sections, a familiarity with solution techniques for single and simultaneous equations 4. For some sections, a familiarity with basic statistics, including the concepts of standard deviation and probability Many of the sections in this book resulted from small instructional sets that were written as stand-alone packages for engineering students enrolled in a mechanical engineering curriculum. In addition, some of the sets and example problems are related to applications in the thermal and fluids areas of mechanical engineering. Although these application examples have been retained, they have been presented as part of more general procedures that will be applicable to other disciplines. Unless a person works with a software package such as Excel on a continual basis, it is easy to forget some of the shortcuts and nuances of operation that accomplish calculation or presentation objectives, viz., procedures for viewing all equations on a worksheet, stretching graphs to multipage proportions, inserting symbols in equations, etc. Such hints have been presented in compact form for the convenience of the reader. The title of this book refers to Excel, but the reader will find several applications that call for a combination of features of Microsoft Word in conjunction with the capabilities of Excel. Most users of Excel will have the complete Microsoft Office Professional Suite, so no problem should arise. Microsoft PowerPoint is also a powerful tool for presentations but is not covered in this book. The Help/Index features of both Excel and Word are of obvious practical utility in working with the software. When appropriate, the reader’s attention is directed to specific index items for further information. There are many books written on Excel and many

1

7326_C001.fm Page 2 Tuesday, March 7, 2006 6:16 AM

2

What Every Engineer Should Know About Excel

specialized references that pertain to particular engineering examples. A list of all references for this book is given in the appendix, and callouts to this list are made at appropriate times in the book. Separate reference lists are not provided at the conclusion of each chapter. Many worked examples are presented throughout the book. For the reader’s convenience, each example is given a title. In some cases, the example title also specifies the calculation principle or technique that is being demonstrated. Extensive use is made of graphs and figures, as well as of printouts of specific spreadsheet segments employed in the examples. Screen dumps that show the worksheet and dialog window contents in perspective are also displayed. The reader will find that many sections in the book can be used independently. This stand-alone nature results from the way many of the topics were generated initially, as well as from an expectation that many readers want information in a compact selfcontained form without having to move back and forth from section to section. To further achieve a compact presentation, explanatory notes are sometimes displayed as embedded text on the pertinent worksheet. When a topic relates to other sections, appropriate notes and references are given.

1.2

Conventions

As described earlier, many of the presentations herein are in a compact form, which allows for more rapid or convenient use. When specifying a procedure that consists of a sequence of operations, we will use the following convention VIEW/TOOLBARS/DRAWING/AUTOSHAPES/choose Freeform instead of the more cumbersome set of instructions: 1. 2. 3. 4. 5.

Click View. Click Toolbars. Click Drawing. Select AutoShapes. Select Freeform.

Another example in Excel is TOOLS/OPTIONS/VIEW/check Formulas which is equivalent to the following: 1. 2. 3. 4.

Click on Tools. Click Options. Select the View tab. Check Formulas box to display all formulas.

Embedding of text boxes and descriptive Word statements in the example Excel worksheets is freely employed to express the instructions in a compact form. In many cases this results in a font size smaller than the main body of the text, but is usually not objectionable.

7326_C001.fm Page 3 Tuesday, March 7, 2006 6:16 AM

Introduction

3

In these examples, the font selected for almost all of the text and graphics nomenclature is Times New Roman. Equations requiring math or Greek symbols have mostly been typed in Word, using symbol shortcuts described at Section 2.3 of Chapter 2. A few complicated formulas have been assembled using Equation Editor. Most of the charts are presented without pattern fill and, of course, without color. A few charts were produced in color and printed in grayscale.

1.3

Outline of Contents

Chapter 2 presents a potpourri of miscellaneous topics in Word and Excel that are applicable to the other chapters. Chapter 3 describes a number of graphing techniques that may be employed in engineering applications. Chapter 4 discusses use of line drawings and other graphics in Word and Excel. Chapter 5 presents a variety of Excel techniques for solving single and multiple linear or nonlinear equations, along with numerical examples of each technique. Chapter 6 presents some other numerical applications, including histograms and multivariable regression analysis, whereas Chapter 7 is devoted to discussion and use of financial functions built into Excel. Chapter 8 presents some optimization techniques that may be exploited with Excel Solver, and finally, Chapter 9 presents some basic operations with pivot tables.

7326_C001.fm Page 4 Tuesday, March 7, 2006 6:16 AM

7326_C002.fm Page 5 Tuesday, March 7, 2006 6:17 AM

2 Miscellaneous Operations in Excel and Word

2.1

Introduction

This chapter contains a collection of hints and reminders for miscellaneous edit, format, and shortcut operations. The reader should take particular note of Section 2.3, which offers detailed suggestions for customizing the keyboard for direct typing of math and Greek symbols. Use of these shortcuts will greatly simplify typing of most equations and mathematical expressions. For those that require more elaborate inserts, directions for employing Equation Editor are given. For those who choose to have digital photo inserts, brief instructions for their use are given in Section 2.9. Some of the format and edit instructions will be repeated from time to time when they are needed in a particular example or discussion.

2.2

Print Screen or Screen Dump

The following are instructions to print the current window or entire screen: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

To activate the current window, press Alt + Print Screen keys. To activate entire screen, press Print Screen key. Click OK (or CLOSE, depending on the screen). Move to a desired document or worksheet by opening the document (START/ DOCUMENTS, etc.). Click the desired cell location in worksheet or location in document. Click EDIT/PASTE; the screen will appear at the desired location. Adjust size and location of screen by dragging, or click FORMAT/PICTURE/ SIZE, etc. Click FILE/PRINT PREVIEW to check the final arrangement. Activate the screen if it alone is to be printed. Make sure screen is not activated if the entire worksheet or document is to be printed. Print as per the usual procedure. See Figures 2.1 and Figure 2.2.

5

7326_C002.fm Page 6 Tuesday, March 7, 2006 6:17 AM

6

FIGURE 2.1

FIGURE 2.2

What Every Engineer Should Know About Excel

7326_C002.fm Page 7 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

2.3

7

Custom Keyboard Setup for Symbols in Word

The following procedure may be used to customize a keyboard setup for symbols: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

Open new document. Click INSERT/SYMBOL. Select Font: Symbol or any other desired style. Click on the desired symbol. Click Shortcut key. Press alternative keys or combination of keys. Click ASSIGN. Click CLOSE. Repeat for as many symbols and characters as desired. Close to return to document.

The customized keyboard can then be applied to all new documents. The symbol font is shown in Figure 2.3, and a suggested custom setup for shortcut keys is shown in Figure 2.4. For convenient use, we suggest that the setup be saved as Word Symbol Template in any desired file and then sent to the desktop as a shortcut. For use in a shared computer, the template can be saved on a floppy disk and then accessed when needed.

FIGURE 2.3

7326_C002.fm Page 8 Tuesday, March 7, 2006 6:17 AM

8

What Every Engineer Should Know About Excel

FIGURE 2.4

2.4

Viewing or Printing Column and Row Headings and Gridlines in Excel

To view or print column and row headings and gridlines: 1. Click FILE/PAGE SETUP/SHEET/PRINT, check Gridlines and Row and Column Headings. See Figure 2.5 and 2.6. 2. Click OK.

2.5

Assorted Instructions

For the following functions, the instructions are as follows (some are repeated in the examples): Plotting of empty cells TOOLS/OPTIONS/CHART/choose empty cells not plotted, or zero. Listing of recently used Word or Excel files TOOLS/OPTIONS/GENERAL/choose number to list. Moving and sizing charts and text boxes on a worksheet To move the entire chart or text box, activate the chart by clicking on CHART AREA, not PLOT AREA, and drag to the new location. Do not drag by side handles. To resize the chart, activate the chart, click on the corners or side handles until a double arrow appears, then drag to desired proportions.

7326_C002.fm Page 9 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word To move the entire text box in small increments, activate the text box. Hold down the Ctrl button and move in small increments with the arrow keys. Adding or removing fill to cells or text boxes Activate the object or area, click on the Fill icon in the Drawing toolbar, select Fill color or pattern or No Fill. Adding or removing line border to text box Activate the object, click on the Line icon on the Drawing toolbar, and select the desired option. Changing border or drawing line weights Activate the object, click on the Line Weight icon on the Drawing toolbar, and make a selection. Editing charts Activate the chart. Click CHART/CHART OPTIONS/select from Titles, Axes, Gridlines, Legend, and Data Labels tabs. Displaying formulas in cells TOOLS/OPTIONS/VIEW/WINDOW OPTIONS/check Formulas. Adding (or deleting) sheet and page numbers FILE/PAGE SETUP/HEADER-FOOTER/choose the desired format. Printing portrait or landscape page orientation FILE/PAGE SETUP/PAGE/choose the desired format. Deleting in Word Previous word delete: Ctrl + Backspace. Previous line delete: Alt + Backspace. Word forward delete: Ctrl + Delete. Subscripts and superscripts in Word Subscript: Ctrl + equal sign. Reverse subscript: Ctrl + equal sign. Superscript: Ctrl + plus sign (using Shift). Reverse superscript: Ctrl + plus sign (using Shift). Protecting Worksheets To prevent accidental typing over formulas or objects in a worksheet, it is possible to lock the material in place by clicking TOOLS/PROTECTION/PROTECT SHEET. This action locks all the cell contents in the worksheet. To exclude some cells from the locking process: 1. Activate the cells (or row or column) to be excluded.

9

7326_C002.fm Page 10 Tuesday, March 7, 2006 6:17 AM

10

What Every Engineer Should Know About Excel

FIGURE 2.5

A 1 2 3 4 5 6 7 8 9 10 11

B C TEXT or FORMULA

D

E

F

G

To change font type or size for entire worksheet, click box in upper left hand corner between row 1 and column A. Make changes. Then click A1 cell to activate changes. NOTE: This will only change fonts in cells; it will not change font in a text box like this. That must be changed by clicking box, etc.

FIGURE 2.6

2. Click FORMAT/CELLS/PROTECTION/remove the check mark from Locked. This exclusion must be made before the locking process for the worksheet. To reverse the protection action, click TOOLS/PROTECTION/UNPROTECT SHEET.

7326_C002.fm Page 11 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

2.6

11

Moving Objects in Small Increments (Nudging)

To move an object by small increments: 1. Select the object by clicking. 2. Press the arrow keys to move object in desired direction. 3. Hold down the Ctrl key while pressing the arrow keys to move the object by onepixel increments. An alternate procedure, which is more complicated, is to click Draw on the Drawing toolbar and then click the Nudge selection for the particular direction.

2.7

Formatting Objects in Word, Including Wrapping

Charts, graphs, drawing objects, pictures, and text boxes may all be copied to Word from other sources, viz., Excel, and then adjusted in size, position, or wrapped with text. The procedure for making these adjustments is as follows: 1. Activate the object, chart, drawing, or picture by clicking. 2. Click FORMAT/Object, AutoShape, Picture, or Text Box. The dialog window will appear as in Figure 2.7a for AutoShape (Drawing) object. 3. Select the tab of interest. In Figure 2.7a the wrapping tab is selected with a choice of Top and Bottom. The same window with selection of the Size tab is shown in Figure 2.7b, which may be used to adjust the size of the object. 4. For a Picture object, the window appears as in Figure 2.7c, and the opportunity to adjust brightness and contrast is offered. If the picture is imported from digitalphoto-editing software, these adjustments will probably have already been made. 5. Changing the position, filling colors, or line color may also be accomplished by choosing the appropriate tab.

2.8

Formatting Objects in Excel

Drawing objects and pictures may be altered in size in Excel by dragging the edges to the desired size or by first activating the object and then clicking FORMAT/ AutoShape(Drawing Object) or Picture. For pictures, the window of Figure 2.8a will appear, which allows modification of picture size and adjustment of brightness and contrast. These latter factors may have already received attention if the picture is imported from digital-photo-editing software. The dialog window for AutoShape is shown in Figure 2.8b, and it too allows for modification of drawing-object size. This text box may also be formatted and sized by activating and then clicking FORMAT/ Text Box. The dialog window appears as in Figure 2.8c.

7326_C002.fm Page 12 Tuesday, March 7, 2006 6:17 AM

12

FIGURE 2.7

What Every Engineer Should Know About Excel

7326_C002.fm Page 13 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

13

(a)

FIGURE 2.8

(b)

7326_C002.fm Page 14 Tuesday, March 7, 2006 6:17 AM

14

What Every Engineer Should Know About Excel

FIGURE 2.8

2.9

(c)

Use of Photo-Editing Software in Word, Including Wrapping

Digital-photo-editing software may be employed to edit digital photos, which can subsequently be copied to a Word document as shown in Figure 2.9. In Figure 2.9a, the digital photo is shown as it was originally recorded. In Figure 2.9b, the photo has been cropped and a texture effect added. In Figure 2.9d, the photo is cropped and adjustments made in contrast and brightness by using the sliders shown in the dialog window of Figure 2.9c. The effects are exaggerated to show in the printing process.

2.10 Copying Cell Formulas: Effect of Relative and Absolute Addresses Copying a cell formula has different results depending on whether absolute cell references are used or not. In cell B4 of Figure 2.10, the formula calls for the square of the value in cell F1. The same result is called for in the formula of cell C4. $F$1 is an absolute cell reference to the value in F1, whereas F1 is called a relative cell reference. The results of copying these two formulas are shown on the worksheet. When B4 is copied to C8, the formula does not change because of the absolute cell reference $F$1. When C4 is copied, an entirely different set of results can be obtained:

7326_C002.fm Page 15 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

FIGURE 2.9

1. When C4 is copied to D8, F1 becomes G5 (1 column to the right, thus F becomes G, and 4 rows down, thus row 1 becomes 5). 2. When C4 is copied to E8, F1 becomes H5 (2 columns to the right, thus F becomes H, and 4 rows down, thus row 1 becomes 5). 3. When C4 is copied to E4, F1 becomes H1 (2 columns to right, thus F becomes H, and the row remains the same, so the row number remains 1). 4. A formula may be copied for successive rows or columns as shown in column A. The formula is clicked, then click EDIT/COPY, and then the cell is dragged down for the desired number of rows, followed by pressing Enter. Note how the formula retains the absolute reference but changes the relative cell locations. 5. Moving a formula does not change the cell addresses in the formula. See “Moving, Formulas” under Help/Index for details.

15

7326_C002.fm Page 16 Tuesday, March 7, 2006 6:17 AM

16

What Every Engineer Should Know About Excel A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

=$F$1*(4.2*B1^2-5.6*C1) =$F$1*(4.2*B2^2-5.6*C2) =$F$1*(4.2*B3^2-5.6*C3) =$F$1*(4.2*B4^2-5.6*C4) =$F$1*(4.2*B5^2-5.6*C5) =$F$1*(4.2*B6^2-5.6*C6) =$F$1*(4.2*B7^2-5.6*C7) =$F$1*(4.2*B8^2-5.6*C8)

B

=$F$1^2

C

D

E

=F1^2

=H1^2 3 1

=$F$1^2

=G5^2

2

=H5^2

4. Formula copied for multiple rows by dragging

FIGURE 2.10

2.11 Copying Formulas by Dragging the Fill Handle Many engineering situations arise in which tabulation or plots of a function are needed for uniform increments in the argument of the function. This operation is very easy to perform in Excel by using the Fill Handle and dragging. In Figure 2.11 we show how this is accomplished for the simple function y = x2 in increments of Δx = 0.1 over the range 1 < x < 2. The start of the range for x is entered in cell A4 as 1. Then, the next value of x is entered in cell A5 as 1.1. Cells A4 and A5 are activated, producing the situation shown in Figure 2.11a. Then, the Fill Handle is clicked and dragged down for the desired number of increments, producing the result shown in Figure 2.11b. The formula for x2 is entered in cell B4 as shown in Figure 2.11a. This cell is activated and the Fill Handle dragged down to copy the formula as shown in Figure 2.11b. In this figure, all the formulas are retained in view by clicking TOOLS/OPTIONS/VIEW/Formulas. Removing the check from the Formulas box produces the final numerical results shown in Figure 2.11c. Display of the formulas is not necessary in the drag process, and the result in Figure 2.11c can be produced by drag-copying cell B4 while in the numerical display mode. Copying of cell formulas could also be accomplished by activating the cell, clicking EDIT/COPY, and then dragging for the number of cells desired, followed by Enter. The use of the Fill Handle is easier. Graphs of the functions may be constructed as described in Chapter 3.

2.12 Shortcut for Changing the Status of Cell Addresses The F4 key may be used to quickly change the absolute or relative status of a cell address. The procedure as applied to the formula in cell B4 of Figure 2.11 is as follows:

7326_C002.fm Page 17 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

17

FIGURE 2.11

1. Activate cell B4 containing the formula. 2. Activate the A4 cell reference in the formula. 3. Press the F4 key until the desired type of cell reference is obtained. Repeated pressing of the F4 key will cycle through the four possible cell references as A4, $A4, A$4, and $A$4. 4. Press Enter.

2.13 Switching and Copying Columns or Rows, and Changing Rows to Columns or Columns to Rows Sometimes the position of data in a column or row needs to be switched in order to provide for a different orientation on a chart. When using x-y scatter graphs (Section 3.3), Excel treats the left column or top row of data as the x or abscissa coordinate. The position of the column on the worksheet may be changed by copying one of the columns (or rows) to a new location by the following procedure. Pivot tables may also be employed for ordering the presentation of data, as described in Section 9.3. 1. Select (activate) the columns or rows of cells to be copied. 2. Click EDIT/COPY. 3. Click the cell that will be the top cell of the new column or the left cell of the new row.

7326_C002.fm Page 18 Tuesday, March 7, 2006 6:17 AM

18

What Every Engineer Should Know About Excel

FIGURE 2.12

4. Click EDIT/PASTE SPECIAL. The window shown in Figure 2.12 will appear. Under Paste, choose Values if new formulas are not to be created. See the earlier discussion on relative and absolute cell locations. 5. If a column is to be switched to a row or a row switched to a column, click Transpose. 6. Click OK.

2.14 Built-In Functions in Excel Excel has hundreds of built-in functions that may be accessed by the function name followed by the syntax that applies to that function. The reader who needs to apply these functions in worksheet formulas will usually be aware of the abbreviations assigned to the functions. For a listing of functions, consult Help and obtain further details by entering such items as the following: Engineering functions Math and trigonometry functions Statistical functions Or, for business users, Financial functions For later reference, the user may wish to print out the lists of functions. A complete description of each function can be called up by the function name from Help, which will

7326_C002.fm Page 19 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

19

TABLE 2.1 Abbreviated List of Built-In Functions Function

Syntax

Absolute value Arccosine Hyperbolic arccosine Arcsine Hyperbolic arcsine Arctangent Hyperbolic arctangent Bessel Function Jn(x) Bessel function Yn(x) Cosine Hyperbolic cosine Error function Exponential Natural logarithm Logarithm to base b Logarithm to base 10 Matrix inversion Matrix multiplication Pi Sine Hyperbolic sine Square root (positive) Square root of Pi Summation Sum of squares

ABS(x) ACOS(x) ACOSH(x) ASIN(x) ASINH(x) ATAN(x) ATANH(x) BESSELJ(n,x) BESSELY(n,x) COS(x) COSH(x) ERF(x) EXP(x) LN(x) LOG(x,b) LOG10(x) MINVERSE MMULT PI( ) SIN(x) SINH(x) SQRT(x) SQRTPI SUM(x1,x2, … 30 values) SUMSQ(x1,x2, … 30 values, or array)

Tangent Hyperbolic tangent Arithmetic average Sum of squares of deviations from arithmetic mean Maximum, median, or minimum Normal distributions

TAN(x) TANH(x) AVERAGE(x1,x2, … 30 values) DEVSQ(x1,x2, … 30 values, or array)

R-squared Sample standard deviation

MAX( ), MEDIAN( ) or MIN(x1, x2, … 30 values) NORMDIST, NORMINV, NORMSDIST, NORMSINV RSQ STDEV(x1,x2, … 30 values)

Population standard deviation

STDEVP(x1,x2, … 30 values)

Financial functions

Arguments x = real number −1 < x < + 1, returns −π/2 to π/2 x = number −1 < x < + 1, returns −π/2 to π/2 x = number x = number, returns −π/2 to π/2 −1 < x < + 1 n = order(integer), x = number n = order(integer), x = number x = angle in radians x = number x ≥ 0, returns value of 0 to 1.0 x = number, returns ex x>0 x > 0, b = base (default b = 10) x>0 See Section 5.5 See Section 5.5 Returns numerical value of π x = angle in radians x = number x≥0 Returns π1/2 Sum of 30 values or array Sum of squares of 30 values or array x = angle in radians x = number Average of 30 values or array = ∑(xi − xmean)2 xmean = arithmetic mean Returns values for 30 values or array See Section 6.5 See Section 3.8 Returns sample standard deviation of 30 values or array Returns population standard deviation of 30 values or array. See Chapter 7

display all syntax requirements. Some examples are given in Table 2.1. Financial functions are discussed in Chapter 7.

2.15 Creating Single-Variable Tables Using the DATA/TABLE Command Copying formulas in successive cells is one way to create a data table as described in Section 2.11. An alternative, and sometimes simpler, procedure makes use of the DATA/ TABLE command with the following steps:

7326_C002.fm Page 20 Tuesday, March 7, 2006 6:17 AM

20

What Every Engineer Should Know About Excel 1. Set aside rows or columns in a worksheet for labeling variables. 2. Choose a column to contain the numerical values of the input variables. Insert input values in this column. Increments may be set as described in Section 2.11 or by direct entry. 3. Type the formula to be calculated in the column to the right of the column in step 2 and one row above. The formula should be written in terms of an input cell that is located apart from the body of cells that will house the final table. Selection of the input cell is rather arbitrary. The only requirement is that it must be located outside the cell range assigned for the table. 4. Select (activate) cells containing values of the input variable, formula to be evaluated, and cells that will contain the results. 5. Click DATA/TABLE. 6. Enter the input cell location for a column table in the dialog window. 7. Click OK. The table will appear. 8. If additional result functions need to be evaluated, enter the formulas for each in the cells adjacent to the formulas in step 3, and repeat steps 5 through 7. 9. The procedure may also be executed using rows for data input. In this case, the formulas are typed in the column to the left of the initial value and one cell below.

Example 2.1: Construction of Table for Simple Functions of a Single Variable We will construct a table for the following three functions of x over the range 0 < x < 5 in increments of 1.0: y1 = x + 1 y2 = x + 2 y3 = x + 3 The worksheet is shown in Figure 2.13. Cell A2 is used for the x label. The three formulas for the functions are listed in cells B2, B3, and B4, respectively, and the cell range to house the table is A2:D7. An input cell apart from this region is chosen as F2 and the formulas written in terms of this cell as shown in Figure 2.13a. The formulas are displayed on the worksheet by clicking TOOLS/OPTIONS/VIEW/Formulas. The table area is selected as shown in Figure 2.13b and DATA/TABLE clicked, producing the window shown at Figure 2.13c. Input column cell F2 is inserted in this window and OK is clicked. The final formula table also appears as shown in Figure 2.13b. Removing the formulas from view produces the final table as shown in Figure 2.13d. A scatter chart of the data table may be constructed using Chart Wizard and will appear as shown below the table in Figure 2.13d. Appropriate titles and nomenclature may be added to the final data table and chart as desired.

7326_C002.fm Page 21 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

21

FIGURE 2.13

2.16 Creating Two-Variable Tables Using the DATA/TABLE Command Two-variable tables may be constructed with a procedure similar to that employed for one-variable tables. Two examples of formulas involving two input variables are: z = (x2 + y2)1/2 and z = (x + 1)(y + 2)

7326_C002.fm Page 22 Tuesday, March 7, 2006 6:17 AM

22

What Every Engineer Should Know About Excel A 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

FIGURE 2.13

2 3 4 5

B 3 4 5 6

C

D 5 6 7 8

4 5 6 7

E

F

9 8 7 6 5 4 3 2 1 0 0

1

2

3

4

5

(d)

The procedure for creating the data table is as follows: 1. Select two input cells apart from the block of cells that will house the data table. These cells will serve as the variables in the formulas. 2. Choose a cell on the worksheet and enter the formula for the function in terms of the two input cells. 3. Enter a list of input values for one variable in the same column as the formula, but below the formula. 4. Enter a list of input values for the second variable in the same row containing the formula, but to the right of the formula. 5. Select (click and drag) the range of cells that are to contain the formula, input values of both variables, and data table. 6. Click DATA/TABLE. 7. The dialog window will appear. Enter the row and column input cells used in writing the formula in step 2 and those corresponding to the input values entered in steps 3 and 4. 8. Click OK. The table will appear.

Example 2.2: Two-Variable Data Table To illustrate the method, we will construct a data table for the function: z = (x2 + y2)1/2 for 1 < x < 5 and 1 < y < 5

7326_C002.fm Page 23 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

23

Increments of x and y are chosen as 1.0. The worksheet is set up as shown in Figure

FIGURE 2.14

2.14. Cells A1 and A2 are chosen as input cells for x and y, respectively, and the formula for z is written in cell C3 as shown in Figure 2.14a. The C column is chosen for x, with the five input values entered. Likewise, row 3 is chosen for y, with 5 corresponding input values. Smaller or larger increments in x and y could be chosen and entered either directly or as described in Section 2.11. Next, the table range C3:H8 is selected by click-dragging. DATA/TABLE is clicked and A1 entered as the input cell for y along with cell A2 as the input cell for x. The entries are shown in the window of Figure 2.14b. OK is clicked and the data table appears as shown in Figure 2.14c, with the formulas displayed. Removal of the formulas gives the final table shown in Figure 2.15. A 3-D wire surface chart of the function is displayed below the final data table. Both the final table and chart may be titled and formatted as needed for the final presentation.

7326_C002.fm Page 24 Tuesday, March 7, 2006 6:17 AM

24

What Every Engineer Should Know About Excel C 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

1 2 3 4 5

D

E

F

1.414214 2.236068 3.162278 4.123106 5.09902

2.236068 2.828427 3.605551 4.472136 5.385165

3.162278 3.605551 4.242641 5 5.830952

4.123106 4.472136 5 5.656854 6.403124

5.09902 5.385165 5.830952 6.403124 7.071068

8

6

4

2 S5 S3

0 1

2

3

4

5

S1

FIGURE 2.15

Problems 2.1. In Excel, click TOOLS/OPTIONS. Copy the Options window to a Word document by pressing Alt + Print Screen, then opening a new Word document, followed by EDIT/PASTE. Adjust size of inserted window by clicking FORMAT/OBJECT/ SIZE. Move the window to new positions by pressing cursor arrows or by dragging. 2.2. Customize the keyboard in Word as shown in Section 2.3 and type the following equations: A = x0/{[1 − (ω/ωn)2] + [2(ω/ωn)(c/cc)]2}1/2 θ/θ∞ = e−(hA/ρcV)τ 2.3. Open a new Excel worksheet. Type in a few comments or equations. Change the font for the worksheet to a different type and size (make your own selections).

7326_C002.fm Page 25 Tuesday, March 7, 2006 6:17 AM

Miscellaneous Operations in Excel and Word

25

2.4. If convenient to do so, insert a digital photo obtained either from a digital camera or scanner into a Word and Excel sheet. Edit the photo using photo-editing software available to you 2.5. Perform the copying operations shown in Figure 2.10. 2.6. Perform the drag-copying process shown in Figure 2.11. 2.7. Open an Excel worksheet and evaluate the following functions: e−0.5 Cosh(2.3) Tanh−1(0.5) Numerical value of π 2.8. Using the DATA/TABLE command, construct a table of values of the function sin(nx) for n = 1, 2, and 3 and x = 1 to 1.5. Choose appropriate increments in x for the calculations. 2.9. Using the DATA/TABLE command, construct a table of the three functions y = x1/2 y = x + 0.3 y = x2 over the range 0 < x < 5. 2.10. Using the DATA/TABLE command, construct a table of the Bessel function J(n,x) for n = 1, 2, 3 and 0 < x < 3. Choose increments in x as desired. 2.11. Using the EDIT/COPY command, transpose the x-y column data in columns A and B into the row data shown:

1 2 3 4 5 6

A x

B y 1 2 3 4 5

C 2 3 4 5 6

D x y

E

F 1 2

G 2 3

H

I

3 4

2.12. Enter the following values in an Excel worksheet: 1, 1.2, 1.1, 1.05, 0.96, 0.95, 1.06, 1.15, 1.21, 0.94, 1.01 and using built-in functions evaluate: y = {[∑(x – xm)2]/n}1/2

7326_C002.fm Page 26 Tuesday, March 7, 2006 6:17 AM

26

What Every Engineer Should Know About Excel where xm = (∑x)/n and n = number of values

2.13. Compare the result of Problem 2.12 with the application of the worksheet functions STDEV and STDEVP to the data points.

7326_C003.fm Page 27 Tuesday, March 7, 2006 6:17 AM

3 Charts and Graphs

3.1

Introduction

The preparation, publication, and presentation of graphs and charts represent a significant portion of engineering practice. In Excel, a majority of such displays are given the designation of x-y scatter graphs. For this reason, we will concentrate our discussion on that type of graphical presentation. Bar graphs and column graphs are discussed briefly in Section 3.19, and surface (3-D) charts are discussed in Section 3.21. Obviously, the interested reader may explore these other graphical possibilities. The display and discussion in Section 3.3 categorizes the five types of scatter graphs available in Excel, along with a general statement of an application for each type. Examples of data presentations using scatter charts are given in this chapter as well as in the application sections of other chapters. Treatment of math and other symbols in graphical displays is discussed in this chapter and in sections of Chapter 4 connected with embedded drawing objects. An important part of the present chapter is concerned with the display and correlation of data using trendlines and the built-in least-squares analysis features of Excel. Examples are given for correlation equations using linear, power, and exponential functions. Section 3.20 discusses formatting and cosmetic adjustments that are available for the various graphs, and Section 3.22 offers a suggestion for default settings of scatter graphs, which are normally the most common type of display. As we have mentioned before, many of the sections are essentially self-contained and can be studied as stand-alone items. To provide for this capability, charts in some sections have been embedded with text along with a reduction in type size. As appropriate, crossreferences are made to related sections of this and other chapters.

3.2

Moving Dialog Windows

A brief set of data is shown in the screen of Figure 3.1a. INSERT/CHART is clicked, producing the Chart Wizard dialog box shown in Figure 3.1b. The dialog box obscures the data, but may be moved out of the way by clicking on the title bar and dragging it to a new position as shown in Figure 3.1c.

27

7326_C003.fm Page 28 Tuesday, March 7, 2006 6:17 AM

28

What Every Engineer Should Know About Excel

FIGURE 3.1

3.3

Excel Chart Wizard Window Showing Choice of x-y Scatter Charts

Different data series may be designated by various shape or styles of data markers, as shown in Figure 3.2: 1. Data plotted with data markers but no connecting line segments: this type of plot is employed for experimental data with considerable scatter but may be fitted with a computed trendline. 2. Data plotted with the data markers connected by smoothed lines as determined by the computer: this type of plot is employed for either calculated points or experimental data with rather smooth variations from point to point. 3. Data plotted as in item 2 but without data markers: this type of plot is most frequently employed for calculated curves and is almost never used for presentation of experimental data because the data points are not displayed.

7326_C003.fm Page 29 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

29

FIGURE 3.2

4. Data points plotted without markers but with points connected by straight line segments: this type of plot is frequently used when points are obtained from a numerical analysis that assumes linear behavior between calculated points. 5. The same as item 4, but with points designated by data markers: this type of plot is sometimes employed for calibration curves in which linear interpolation between data points is assumed.

3.4

Selecting and Adding Data for x-y Scatter Charts

In setting up scatter charts, the x-axis will be either the left column or top row of data, depending on whether columns or rows are chosen for the data series. The y-axis will be the remaining columns or rows. After the chart is established, the addition of data will be as new y-axes regardless of their location relative to the column or row taken as the xaxis. The data selection procedure is as follows: 1. Click-drag cells for the x-axis while holding down the Ctrl button.

7326_C003.fm Page 30 Tuesday, March 7, 2006 6:17 AM

30

What Every Engineer Should Know About Excel 2. Release click on the mouse, move the pointer to the column for the first y-axis data while still holding down the Ctrl button and then click-drag cells for the first y-axis data. 3. Continue this procedure for successive y-axes data, still holding down the Ctrl button.

3.5

Changing and Adding Data for Charts Using the SOURCE DATA Command

Data for charts can be added or changed as follows: 1. 2. 3. 4. 5.

6. 7. 8.

3.6

Activate the chart. For a separate chart sheet, click the tab for the chart sheet. Click CHART/SOURCE DATA. Select the worksheet containing data to be added. To view worksheet cells and data, click the collapse button at the right end of DATA RANGE dialog box as shown on the screen. Select the replacement data cells to be added as described in Section 3.4. These replacement cells may be chosen to include or omit the old data cells. To simply add a data series while retaining the old data, see the description of the ADD DATA command in Section 3.6. Click the collapse (expand) button (see Figure 3.3) again at right end of the dialog box displayed at top of worksheet. The SOURCE DATA dialog box will reappear. Click OK, which will install the new replacement data on the chart. Make cosmetic and other adjustments to the chart as needed.

Adding Data to Charts Using the ADD DATA Command

Data can be added to charts as follows: 1. 2. 3. 4.

Activate the chart. For a separate chart sheet, click the tab for the chart sheet. Click CHART/ADD DATA. Select the worksheet containing data to be added. If the ADD DATA dialog box obscures the view of data, click the collapse button at the right end of DATA RANGE text box or drag the dialog box into a new location away from the data columns. 5. Select the data cells to be added as the new y-axis data by clicking and dragging as described in Section 3.4. 6. Click the collapse (expand) button again at right end of the dialog box. The ADD DATA dialog box will reappear.

7326_C003.fm Page 31 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

31

FIGURE 3.3

7. Click OK, which will install new data on the chart. Note that if a replacement of all the chart data is desired, the procedure using the SOURCE DATA command is followed. 8. Make cosmetic and other adjustments to the chart as needed.

3.7

Adding Trendlines and Correlation Equations to Scatter Charts

Click on the chart to activate it. Then click CHART/ADD TRENDLINE/TYPE/select the type of trendline. Then, click the OPTIONS tab to select Display Equation on Chart and R-squared. Adjust the location, size, and font of the equation and R2 on the chart as needed. See Section 3.9 and Section 3.10 for specific examples.

3.8

Equation for R 2

The equation employed by Excel for calculation of R2 in the trendline fits is given by R2 = [n∑xiyi − (∑xi)(∑yi)]2/[n∑xi2 − (∑xi)2][n∑yi2 − (∑yi)2]

(3.1)

7326_C003.fm Page 32 Tuesday, March 7, 2006 6:17 AM

32

What Every Engineer Should Know About Excel

R2 is called the coefficient of determination, whereas R is called the correlation coefficient. This particular equation expresses what is called the Pearson correlation coefficient, which is callable by the PEARSON worksheet function. A calculation of R2 separate from the trendline determinations may also be obtained by calling either the worksheet function RSQ or PEARSON. See Help/Index for the proper syntax for execution of these functions. The R2 displayed with the graphical trendline is expressed by R2 = 1 −

SSE SST

where SSE is the sum of the squares of the error from the correlating trendline, or SSE = ∑(yi − yic)2 and SST is the sum of squares of deviations from the arithmetic mean, ymean = (∑yi)/n, and may be expressed in the form SST = (∑yi2) − (∑yi)2/n where yic represents the value of y on the linear trendline fit. For a perfect match between data points yi and the trendline, R2 = 1.0. For exponential, power, and polynomial trendlines Excel uses a transformed regression model. Note that these calculations are equivalent to using a population standard deviation instead of a sample standard deviation. Still, a perfect fit will be obtained when yi = yic. SST may also be calculated in terms of the population standard deviation function STDEVP through the relation SST = n×[STDEVP(yi)]2

3.9

Correlation of Experimental Data with Power Relation

A number of physical phenomena follow a power law relation between variables. Examples are Nu = CRen for forced convection and Nu = C(GrPr)m for free convection heat transfer. The general power law relation has the form y = axb

(3.2)

Taking the logarithm of both sides of the equation gives Log y = Log a + bLog x

(3.3)

7326_C003.fm Page 33 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

33

which is a linear relation between Log y and Log x. When x and y are plotted on a log–log graph, b will be the slope of the line and Log a will be the intercept at x = 1.0 (see Section 3.10). When trying to fit experimental data with the power law relation, scatter in the data will normally occur and a least-squares analysis should be employed to determine the best fit. A correlation coefficient may also be calculated to indicate the goodness of fit. Excel may be used to (1) display the data on a log–log plot, (2) calculate the values of the constants a and b using a least-squares analysis, (3) display the resultant correlation trendline, and (4) display the correlation equations on the plot. The Excel procedure is as follows: 1. List the data in two columns. Label columns as appropriate. Consider discarding any data points that appear to be in gross error. This step may be deferred until after the data plot is obtained. See step 7. 2. Select the data to be plotted. 3. Click Chart Wizard or INSERT/CHART. a. Select the scatter chart without connecting line segments (type 1 chart). b. Select the data range of cells. c. Input the chart title and values for x- and y-axes. Under AXES click values for both x and y. Under GRIDLINES, select as appropriate. Under DATA LABELS, None is probably appropriate. d. Click FINISH. The chart will appear. 4. Click the chart to be edited. Click either x- or y-value axis — FORMAT AXIS will appear. Under SCALE, click Logarithmic Scale. Select the minimum and maximum values for the scale (nonzero values for log scale) and the value for crossing the other axes. Repeat for other value axes. Then repeat FORMAT AXIS/PATTERNS to set tick marks for both major and minor axes, with labels next to the axis. FONT may also be adjusted at this point if desired. 5. After step 4 is completed, click the chart again. Then click CHART/ADD TRENDLINE/TYPE/POWER. Click OK. Then click the chart again, followed by CHART/ADD TRENDLINE/OPTIONS, and click Display Equation on Chart and Display R-squared Value on Chart. Click OK. 6. Inspect the final graph. Does the trendline appear to represent the data? If not, the power relation may not be correct for the physical application. This step is important! A correlation equation should NEVER be accepted without visual confirmation of agreement with the experimental data points. The computer will perform the trendline analysis as instructed, but cannot assure that the functional form selected is correct. 7. Examine the individual data points in the final plot. If some points appear to be widely scattered from the main body of data, consult the original data sheets for possible errors or erratic behavior in the experiment. Consider eliminating suspicious points. 8. If a decision is made to eliminate points as discussed in step 7, delete the respective entries in the data cells. The deletions will appear on the chart, and a new trendline and correlation equation will be displayed, based on the remaining data points. 9. Make final adjustments to the cosmetics of the chart, fonts, titles, etc. If a large number of data points are involved, some adjustment of the size of data markers or line width for the trendline may be in order.

7326_C003.fm Page 34 Tuesday, March 7, 2006 6:17 AM

34

What Every Engineer Should Know About Excel

x 1 2 3 4 5 6 7

y 1.5 3 5 15 27 34 48

100 1.8929

y = 1.0554x 2 R = 0.9498 10

1 0

(a)

x 1 2 3 4 5 6 7 8

y 20 6 56 25 42 12 87 99

0.7598

100

y = 11.103x 2 R = 0.299

10

1 0

(b)

FIGURE 3.4

Two examples of power law correlation plots are shown in Figure 3.4. One has a rather good fit, whereas the other has a lot of scatter. In the latter case, one should suspect that either the data are bad or that a power law relation does not fit the physical situation.

3.10 Use of Logarithmic Scales The data are first plotted on a linear graph as shown in Figure 3.5a, indicating a decaying exponential or inverse power relation. Logarithmic scales are then selected by clicking on each value axis, then click FORMAT AXIS/SCALE/check Logarithmic scale as shown in the screen of Figure 3.5b. The result is the graph in Figure 3.5c with the x-axis in an inconvenient position at the top of the graph. The y-axis value is again selected. Then click FORMAT AXIS/SCALE as shown in Figure 3.5d. The “Value (X) axis crosses at:” is changed to 0.01 (the lower edge of the graph), and the result is shown in the graph of Figure 3.5e. Next, a trendline is added by clicking on the data, then click GRAPH/ADD TRENDLINE/TYPE/highlight Power as shown in the screen of Figure 3.5f. Then, select the OPTIONS tab and check “Display equation on chart” and “Display R-squared value on chart” as shown in the screen of Figure 3.5h. The result is the graph in Figure 3.5g. A power relation does fit the data.

7326_C003.fm Page 35 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

35

FIGURE 3.5

3.11 Correlation with Exponential Functions The exponential function y = exp(−0.1x) is tabulated and shown first as a linear plot in Figure 3.6a with a linear trendline fit, which obviously does not fit. Second, a linear plot with exponential trendline fit is shown in Figure 3.6b with perfect correlation. Third, the function is plotted on a semilog graph that displays the function as a straight line in Figure 3.6c. Again, an exponential trendline is fitted with perfect correlation. Inspection of the visual display is needed to evaluate the trendline fit. For comparison, the final two plots of Figure 3.6d and Figure 3.6e show fits of second- and third-degree polynomials. The

7326_C003.fm Page 36 Tuesday, March 7, 2006 6:17 AM

36

What Every Engineer Should Know About Excel

FIGURE 3.5 (continued)

third-degree one shows a perfect correlation. Polynomials may frequently be employed to obtain a good fit when the functional form is uncertain.

3.12 Use of Different Scatter Graphs for the Same Data Figure 3.7 shows six scatter plots of a set of hypothetical experimental data displayed in the upper-left corner of the sheet. Figure 3.7a is a type 1 scatter graph, Figure 3.7b is a type 5 chart, and Figure 3.7c is a type 3 chart — all plotted with linear scales on both axes

7326_C003.fm Page 37 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

37

exp(-0.1x) 1

Linear Chart-Linear Trendline

0.8187308 0.7408182

1

0.67032 0.6065307 0.5488116 0.4965853

y = -0.0443x + 0.8674

0.8

2

R = 0.9194

0.6 0.4

0.449329

0.2

0.4065697

0 0

0.3678794

25

1

y = exp(0.1x)

1.2

y = exp(-0.1x)

0.9048374

Semi-Log Chart-Exponential Trendline 5 10 15 20

0

5

10

0.3328711

x

15

20

y=e

0.1

25

x

c)

(a

0.3011942 0.2231302 0.1353353

-0.1x

2

R =1

Linear Chart-Exponential Trendline 1.2

y = exp(-0.1x)

1

y=e

0.8

-0.1x

2

R =1

0.6 0.4 0.2 0 0

5

10

x

15

20

25

(b)

y = 0.002x

0.8 0.6 0.4 0.2

2

Third Degree Polynomial

- 0.0818x + 0.9777

y = exp(-0.1x)

y = exp(-0.1x)

Second Degree Polynomial 1.2 1

2

R = 0.9978

0 0

5

10

15

20

25

1.2 1 0.8 0.6 0.4 0.2 0

y = -7E-05x

3

+ 0.004x

0

5

10

- 0.0965x + 0.9977

15

20

25

x

x

(d

2

2

R =1

e)

FIGURE 3.6

(see Section 3.3). Figure 3.7d, Figure 3.7e, and Figure 3.7f are the same types of plots, but with logarithmic scales on the axes (see Section 3.10). From the graph in Figure 3.7d, it can be seen that the data fall approximately on a straight line so a power law relation might be anticipated, and the corresponding trendline inserted as shown along with the correlation equation and value of R2 (see Section 3.9). Inspecting the data plot in Figure 3.8a, four points are circled as shown in Figure 3.8a along with the first data point indicated by the arrow shown in Figure 3.8d of that page. These points appear out of place and are, hence, suspect. The first data point looks particularly odd. If these five points are eliminated as shown in Figure 3.9, a much better correlation results.

7326_C003.fm Page 38 Tuesday, March 7, 2006 6:17 AM

38

What Every Engineer Should Know About Excel

x

y

1 1.2 1.3 1.5 1.6 2 2.1 2.4 2.9 3.1 3.5 3.7 4.1 4.2 5.3 5.4 5.9 6.3 7 7.2 7.6 8.1

0.1 1.4 1.5 2.5 2 4.2 4.1 15 7 9.6 11.2 25 15 14.9 26 25.3 21 29 65 52 65 72

80 70

100

60 50 10

40

y = 0.6523x 2.2761 2 R = 0.881

30 1

20 10 0 0

2

4

6

8

0.1

10

0

(a)

(d

80 70

100

60 50 10 40 30 1

20 10 0

0.1 0

2

4

6

0

1

(b

10

e)

80 70 100

60 50

10

40 30

1

20 10

0.1

0 0

2

4

6

c) FIGURE 3.7

0

0

(f)

7326_C003.fm Page 39 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs x 1 1.2 1.3 1.5 1.6 2 2.1 2.4 2.9 3.1 3.5 3.7 4.1 4.2 5.3 5.4 5.9 6.3 7 7.2 7.6 8.1

y 0.1 1.4 1.5 2.5 2 4.2 4.1 15 7 9.6 11.2 25 15 14.9 26 25.3 21 29 65 52 65 72

39

80 70

100

60 50 10 40 30 1

20 10 0 0

2

4

6

8

0.1

10

0

(a

(d

80 70 100 60 50 10 40 30 1

20 10

0.1

0 0

2

4

6

0

0

b)

e)

80 70 100

60 50

10

40 30

1

20 10

0.1

0 0

2

4

6

(c) FIGURE 3.8

8

0

10

(f)

7326_C003.fm Page 40 Tuesday, March 7, 2006 6:17 AM

40

What Every Engineer Should Know About Excel x 1.2 1.3 1.5 1.6 2 2.1 2.9 3.1 3.5 4.1 4.2 5.3 5.4 6.3 7.2 7.6 8.1

y 0.1 1.4 1.5 2.5 2 4.2 4.1 15 7 9.6 11.2 25 15 14.9 26 25.3 21 29 65 52 65 72

80 70 60 50 40 30 20 10 0 0

2

4

6

8

10

(d) 80 70

100

60 50

10

40 30 1 20 10 0.1

0 0

2

4

6

8

0

10

(e) 80 70 100

60 50

10

40 30

1

20 10

0.1

0 0

2

4

6

0

0

(f) FIGURE 3.9

7326_C003.fm Page 41 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs A

41 B

C

D

E

F

1 x 2

J(x,0)

J(x,1)

J(x,2)

J(x,3)

J(x,4

3 0

=BESSELJ(A3,0) =BESSELJ(A4,0) =BESSELJ(A5,0) =BESSELJ(A6,0) =BESSELJ(A7,0) =BESSELJ(A8,0)

=BESSELJ(A3,1) =BESSELJ(A4,1) =BESSELJ(A5,1) =BESSELJ(A6,1) =BESSELJ(A7,1) =BESSELJ(A8,1)

=BESSELJ(A3,2) =BESSELJ(A4,2) =BESSELJ(A5,2) =BESSELJ(A6,2) =BESSELJ(A7,2) =BESSELJ(A8,2)

=BESSELJ(A3,3) =BESSELJ(A4,3) =BESSELJ(A5,3) =BESSELJ(A6,3) =BESSELJ(A7,3) =BESSELJ(A8,3)

=BESSELJ(A3,4) =BESSELJ(A4,4) =BESSELJ(A5,4) =BESSELJ(A6,4) =BESSELJ(A7,4) =BESSELJ(A8,4)

4 =A3+$H$3 5 =A4+$H$3 6 =A5+$H$3 7 =A6+$H$3 8 =A7+$H$3

A 1 x 2 3 4 5 6 7 8 9

0 0.3 0.6 0.9 1.2 1.5 1.8

B

C

D

E

F

J(x,0)

J(x,1)

J(x,2)

J(x,3)

J(x,4)

1 0.97763 0.912 0.80752 0.67113 0.51183 0.33999

0 0.14832 0.2867 0.40595 0.49829 0.55794 0.58152

0 0.01117 0.04367 0.09459 0.15935 0.23209 0.30614

0 0.00056 0.0044 0.01443 0.03287 0.06096 0.0988

0 2.1E-05 0.00033 0.00164 0.00502 0.01177 0.0232

G

H

x 0.3

Dx 0.3

FIGURE 3.10

3.12.1

Observations

The charts in Figure 3.7c and Figure 3.7f do not convey much information about the data and do not give a reader any hint of what might be going on with the experiment. Looking at the other charts would certainly not give one the impression of a smooth variation of y as a function of x. The charts in Figure 3.7b and Figure 3.7e are somewhat better, but those in Figure 3.7a and Figure 3.7d give the best impression of the scatter of data. The chart in Figure 3.7d, because it indicates that the data are approximately on a straight line in a log–log plot, gives the clue that a power relation may apply if one deletes the first data point, which appears totally skewed. As we have stated before, one should never leave out the data markers when plotting experimental results. In some other chart examples, involving plots of calculated points, we will see that the use of smooth curves as in Figure 3.9c and Figure 3.9f will be quite appropriate.

3.13 Plot of a Function of Two Variables with Different Chart Types This example illustrates how it is possible to present the plot of a function or data in different chart types to convey somewhat different impressions of the function. The Bessel function Jn (x) is chosen for presentation because of its attractive appearance as a damped sine wave. The function is callable in Excel as BESSELJ(x,n). The worksheet is set up as shown in Figure 3.10, with column A listing the values of the argument x to be incremented using Dx selected in cell H3. These increments may be selected as coarse or fine as desired. Columns B through F compute the Bessel functions as a function of the argument x and orders n = 0 to 4. The formulas are copied for as many rows as needed for the plot. In Figure 3.10, the copying is shown for just a few rows. Also shown is a printout of a few of the numerical values of the functions. The different types of charts selected for presentation are shown in Figure 3.11a through Figure 3.11f. The chart in Figure 3.11a is a typical type 3 scatter graph with smooth curves

7326_C003.fm Page 42 Tuesday, March 7, 2006 6:17 AM

42

What Every Engineer Should Know About Excel 1

0.8

0.6

0.4

0.2

0 0

2

4

6

8

10

12

14

16

-0.2

-0.4

-0.6

(a) Type 3 x-y scatter chart 1.2 1

0.8 0.6 0.4

0.2

-0.2

-0.4 -0.6

(b) Area chart with overlapping 1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4

(c) Surface chart, 3-D wire frame surface without color

FIGURE 3.11

52

49

46

43

40

37

34

31

28

25

22

19

16

10

13

7

4

1

-0.6

S1

53

51

49

47

45

43

41

39

37

35

33

31

29

27

25

23

21

19

17

15

13

9

11

7

5

3

1

0

7326_C003.fm Page 43 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

43

FIGURE 3.11 (continued)

connecting the points and no data markers. The chart in Figure 3.11b is an area chart showing the curves as overlapping with a shading effect. The chart in Figure 3.11c is a surface chart with a wire frame 3-D surface without color. Charts in Figure 3.11d through Figure 3.11f all involve selection through the sequence of clicks: CHART/CHART TYPE/AREA/Area with 3-D Visual Effect and then CHART/3D View/Rotate Vertical. For this presentation, three views were generated as shown in Figure 3.11d to Figure 3.11f. Zero or 360° represents a straight-ahead view with no 3-D effects showing. The charts are generated in different colors but printed in grayscale here. This presentation enables one to look at the “front” or “back” of functions or data. The window for the rotation selection process is also shown in Figure 3.12. Other effects such as perspective, etc., are also available as indicated in the 3-D View dialog window. Figure 3.13 provides further illustrations of the results of using different rotation and elevation views for the 3-D display.

FIGURE 3.12

7326_C003.fm Page 44 Tuesday, March 7, 2006 6:17 AM

44

What Every Engineer Should Know About Excel

FIGURE 3.13

3.13.1

Changes in Gap Width and Chart Depth on 3-D Displays

The depth of each of the function displays and the width of the separation gap between them may be adjusted with the following procedure: 1. Activate the data series by clicking on it. 2. Click FORMAT/SELECTED DATA SERIES/OPTIONS and make changes in chart depth and gap width as desired. The Format Data Series window is shown in Figure 3.14.

3.14 Plots of Two Variables with and without Separate Scales Two sets of data (curves) with either markedly different ranges or units may be plotted as two data series on the same scatter graph. Both the abscissas (x-coordinate) and ordinates (y-coordinate) may have different scales or units. The procedure as shown in Figure 3.15 is as follows:

7326_C003.fm Page 45 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

45

FIGURE 3.14

1. Plot both sets of points using the normal procedure for scatter graphs, as shown in Figure 3.15. 2. Click on the first set of data (series) to cause the Format Data Series box to appear. Click AXES. The primary axes are lower for the abscissa and are to the left for the ordinate. Secondary axes are the upper ones for the abscissa and are to the right for the ordinate. Select the desired option. The scale of the graph for that series will be expanded or contracted and the data replotted accordingly, as shown in Figure 3.15b. 3. Repeat for the other set of data (series) and select the other axes. Again, new scales will appear and the points replotted, as shown in Figure 3.15c. 4. Click on each of the four axes and attach titles (labels) of indicated variables and units, tick marks, etc., as appropriate. The data sets may be marked or titled with a separate legend box, different color lines, or box labels inserted directly on the chart itself. Cosmetic features may be added as necessary. The final result is shown in Figure 3.15d.

3.15 Charts Used for Calculation Purposes or G&A Format Figure 3.16 shows a type 3 x-y scatter chart for display of computed values of R, the capital recovery factor used in financial calculations. The Excel table of values is shown in the upper-part of the worksheet, followed by an equation for R that was composed in Word and copied to the Excel worksheet. The use of smoothed curves without data markers is obviously a good choice for the presentation in this example.

7326_C003.fm Page 46 Tuesday, March 7, 2006 6:17 AM

What Every Engineer Should Know About Excel

FIGURE 3.15

46

7326_C003.fm Page 47 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

47 I 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2

R(5) 0.206 0.2122 0.2184 0.2246 0.231 0.2374 0.2439 0.2505 0.2571 0.2638 0.2706 0.2774 0.2843 0.2913 0.2983 0.3054 0.3126 0.3198 0.3271 0.3344

R(10) 0.105582 0.111327 0.117231 0.123291 0.129505 0.135868 0.142378 0.149029 0.15582 0.162745 0.169801 0.176984 0.18429 0.191714 0.199252 0.206901 0.214657 0.222515 0.230471 0.238523

R(15) 0.072124 0.077825 0.083767 0.089941 0.096342 0.102963 0.109795 0.11683 0.124059 0.131474 0.139065 0.146824 0.154742 0.162809 0.171017 0.179358 0.187822 0.196403 0.205092 0.213882

R(20) 0.055415 0.061157 0.067216 0.073582 0.080243 0.087185 0.094393 0.101852 0.109546 0.11746 0.125576 0.133879 0.142354 0.150986 0.159761 0.168667 0.17769 0.18682 0.196045 0.205357

R(25) 0.045407 0.05122 0.057428 0.064012 0.070952 0.078227 0.085811 0.093679 0.101806 0.110168 0.11874 0.1275 0.136426 0.145498 0.154699 0.164013 0.173423 0.182919 0.192487 0.202119

R = i/[1 - (1 + i) -n] 0.4

0.35

0.3

n =5

R

0.25

0.2 n = 15 n = 10

0.15 n=5

n = 20

n = 25

0.1

n = 25

n = 20

n = 15

n = 10

0.05

0 0

0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2

Interest Rate, I

FIGURE 3.16

0.21

7326_C003.fm Page 48 Tuesday, March 7, 2006 6:17 AM

48

What Every Engineer Should Know About Excel

CAPITAL RECOVERY FACTOR 0.4 n=5

R

0.3

n = 10

0.2

n =25

0.1

0 0

0.1

0.2

0.3

Interest Rate, I FIGURE 3.17

3.15.1

G&A Chart

In Figure 3.17 the same information is plotted in what we choose to call a G&A Chart (for Generals and Admirals). Still, a type 3 scatter chart is employed, but large, bold fonts are used for axis and chart labels. Minor gridlines are deleted, and a light pattern is added to the body of the chart for cosmetic effects. This might be called a “broad brush” chart as it shows main trends. It cannot be used for calculation purposes. On the other hand, the chart in Figure 3.16 can be used to read rather precise values of R.

3.16 Stretching Out a Chart from a Single Chart Page A chart that needs to extend broadly from top to bottom or side to side, but which appears compressed on a single page, can be stretched out by the following: 1. Click EDIT/COPY from chart on chart page.

7326_C003.fm Page 49 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs 2. 3. 4. 5. 6. 7.

8. 9. 10. 11. 12.

49

Open a new “sheet.” Click upper-left corner cell (A1) of the new sheet or somewhere thereabouts. Click EDIT/PASTE. Click on the background to “deactivate” the chart. Click FILE/PAGE SETUP. Choose Adjust To (“% size”) or Fit To. Choose Portrait or Landscape depending on chart orientation. Note that both % size and Fit To cannot be selected at the same time. Once % size is chosen, the number of pages is automatically set. Or, when the number of pages is set for the Fit To, the program will first try a setup at 100% size to fit within the number of pages selected. This may not require all the pages specified. If a fit does not work at 100% size, the program will automatically reduce the chart size to fit the number of pages specified. Thus, a wide figure specified at 100% size might require three pages in the portrait format, but only two pages in the landscape format. If Fit To 2 pages is specified, the program will automatically reduce the size in the portrait format, while still retaining 100% size in the landscape format. The % size will then appear in the box on the Page Setup dialog screen. Several tries, with the use of Print Preview, may be needed to obtain the desired setup for the final printout. Of course, all these adjustments are in addition to those that may be affected by stretching or squeezing the original chart proportions before or after it is copied to the sheet for these operations. Because of screen viewing limitations, there is only so much that can be conveniently accomplished on the single chart sheet. Click OK. Click FILE/PRINT PREVIEW to see the setup. If desired, comments or labels can be entered in appropriate cells of the new sheet or by using text boxes. This technique may be employed to construct poster-sized charts assembled from several 8 1/2 × 11 pages physically pasted together. The same effects may be achieved with a printer with built-in poster capabilities.

3.17 Alternate Chart Sizing Procedure Using MS Word Although the previous procedure is a satisfactory way to accomplish a stretched version of the chart, a somewhat easier protocol may be exercised by transferring the chart to a MS Word document as a picture (Enhanced Metafile; see Section 4.3). The procedure is as follows: 1. 2. 3. 4.

Activate the chart if it is embedded in a worksheet. Click EDIT/COPY after activation or immediately if copying a chart page. Open a new MS Word document. Click EDIT/PASTE SPECIAL/PICTURE (Enhanced Metafile). The chart will appear in document form. 5. While the chart is activated (if it has become deactivated, click to activate), click FORMAT/PICTURE/SIZE and make adjustments in size as desired. If the chart

7326_C003.fm Page 50 Tuesday, March 7, 2006 6:17 AM

50

What Every Engineer Should Know About Excel (picture) proportions are to be changed, be sure to remove the check from the “Lock aspect ratio” box and adjust the width and length dimensions separately (see Section 2.7). MS Word will automatically adjust the number of pages to accomplish the final chart size. Further adjustments in the number of pages to accommodate the chart may be made by changing the page margins by clicking FILE/PAGE LAYOUT/MARGIN and setting larger or smaller margins and headers or footers. 6. Periodic checking of FILE/PRINT PREVIEW should be employed to examine the chart appearance before the final process is executed. 7. At the same time the chart size and proportions are adjusted, addition of labels, symbols, or text boxes may be accomplished as discussed in Section 4.3.

3.18 Calculation and Graphing of Moving Averages Moving averages are employed as forecasting tools in applications ranging from stock market predictions to estimations of sales and inventory trends. The calculation assumes that a forecast value of the variable under consideration may be made as a simple arithmetic average of the preceding actual values over a selected number of time periods. The number of periods is chosen to fit the situation. In many cases, moving averages are charted using several calculation intervals to gain comparative insights into the specific trends. The formula for the moving average calculation is n

Ft = (1/n)

∑A

t-i

(3.4)

t+ 1-i

(3.5)

i=1

or n

Ft+1 = (1/n)

∑A i =1

where Ft = forecast value of the variable at time t n = number of previous time periods over which the average is to be computed (Excel uses a default value of 3 periods if some other number is not specified) At = actual value of the variable at time t Thus, for n = 4 time intervals, we would have forecast values at times t = 6 and 7 of F6 = (A5 + A4 + A3 + A2 )/4 F7 = (A6 + A5 + A4 + A3)/4 Excel performs the calculation for a set of specified At values and presents a graph of the forecast values Ft along with the actual values for comparison. It is an easy matter to

7326_C003.fm Page 51 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

51

FIGURE 3.18

change the number of periods for the moving average calculation to examine the influence of this selection on forecasting trends.

Example 3.1: Weather Temperature Trends Figure 3.18 displays three types of weather temperature data as indicated in the nomenclature for the figure: (a) TV fifth day future forecasts for high and low temperatures, (b) actual high and low temperatures, and (c) long-term average or normal high and low temperatures. We will present results of moving average calculations for 10-, 30-, and 60d intervals over a 220-d total time period. The calculations will be made for the following: 1. The TV fifth day future forecast for daily high temperature in °F. 2. The long-term average high temperature in °F. The moving average calculation is CALLED by clicking TOOLS/DATA ANALYSIS/ Moving average, which results in the display of the Moving Average dialog box as shown in Figure 3.19. Entries are made in this box as described in the following paragraphs. The input range is specified for the TV forecast data as in column C3:C223. These worksheet data are not displayed because of the large number of entries. The first two cells of the column are labels, so the actual data points are in C3:C223. If a label is in the first row of the data column selected, that box should be checked. If not, Excel will label the variables as Values and the abscissa as Data Point when the graph is displayed. The abscissa in this case will be labeled Days, and we will insert the proper titles for the graph coordinates in the editing process. The interval for this problem is 10, 30, or 60 d.

7326_C003.fm Page 52 Tuesday, March 7, 2006 6:17 AM

52

What Every Engineer Should Know About Excel

FIGURE 3.19

Specifying the upper-left cell of the output table automatically sets the output range for the forecast values. For the case shown in the dialog box, AD3 is chosen for the 10-d averaging. If the standard error box is checked, a second result column adjacent to the output forecast values will be reserved. We will discuss the equation used for the standard error calculation later in Section 3.18.1. A chart output should be selected. The chart will appear embedded on the calculation worksheet. In many cases, this chart will require considerable editing to bring it to acceptable visual proportions. The chart will contain plots of both the actual values At given in the specified data column and the computed forecast values Ft. The forecast plot will not start until t equals the interval value. Figure 3.20 and Figure 3.21 show the 10- and 30-d moving averages for the TV forecast data. Clearly, the 10-d average follows the actual data more closely than the 30-d average. The actual temperature rises through spring and summer, and the moving average lags this advance, with the lag increasing as the averaging interval is increased. If the process were carried into the fall and winter season, we would find that the moving averages would still lag the actual temperatures and, thus, fall above the actual temperatures on the chart. Figure 3.22 presents 10-, 30-, and 60-d moving averages for the long-term average normal high temperatures, along with the actual temperature values upon which the averaging calculations were based. The jagged nature of the actual temperature curve results from data rounded to the nearest degree. It should be a smooth curve. The

7326_C003.fm Page 53 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

53

110

Forecast Hi Temperature

100

Ten Day Moving Average

Actual

90

Forecast

80

70

60

50 0

50

100

150

200

250

150

200

250

Day

FIGURE 3.20

110

Thirty Day Moving Average

Forecast Hi Temperature

100

Actual

Forecast

90

80

70

60

50 0

50

100

Day FIGURE 3.21

7326_C003.fm Page 54 Tuesday, March 7, 2006 6:17 AM

54

What Every Engineer Should Know About Excel 100 95 Normal Hi Temperature

90 Ten Day Avg

Moving Average

85 80

Thirty Day Avg

75 70 65 60 55 50 0

50

100

150

200

250

Days FIGURE 3.22

moving average curves exhibit the lag behavior shown previously for the forecast temperatures in Figure 3.20 and Figure 3.21. The larger the number of time intervals, the greater the lag. Some stock market enthusiasts claim that when the charted price of a stock breaks through a 30- or 60-d moving average, the future trend will be in the direction of the breakthrough. If the stock breaks on the upside, it should be bought. If it breaks on the downside it should be sold or shorted. Reliable data on this effect are difficult to obtain.

3.18.1

Standard Error

The standard error for the moving average function is defined by: S(t +1) = {∑[(At+1-I - Ft+1-I)2/n]}1/2

(3.6)

This function has the same form as a population standard deviation. The standard error for the 10-d moving average of Figure 3.20 is plotted in Figure 3.23. The decreasing trend with the approach of summer indicates less volatility in temperature as the calendar progresses. This just means that Texas is predictably hot in the summer — day after day.

7326_C003.fm Page 55 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

55

10

8

S(t+1)

Standard Error for Ten-Day Moving Average 6

4

2

0 0

50

100

150

200

250

Days FIGURE 3.23

3.19 Bar and Column Charts Although not as widely used as scatter charts, bar and column charts have a number of applications in engineering and are rather straightforward to create in Excel. The data are simply activated and the appropriate bar or column chart selected with Chart Wizard. Editing with choices of fonts, fill patterns, line widths, etc., is essentially the same as with any other chart, but the editing of gap widths and depths between columns deserves some special mention. To perform this editing, in either 2-D or 3-D bar or column charts, the data series are first activated by double-clicking on the chart. The Format Data Series window will then appear as shown in Figure 3.24 for a 2-D chart or Figure 3.25 for a 3-D chart. In either case, the OPTIONS tab should be selected. For a 2-D bar or column chart, Gap width is the spacing between the bars representing each data point. Overlap indicates the spacing between the adjacent data points. Negative Overlap indicates a space between the columns. Figure 3.24 illustrates the results of changing both parameters for a simple data system. In a 3-D bar or column chart, the parameters of Gap depth, Gap width, and Chart depth may be varied to change the appearance of the final chart presentation. Figure 3.25 illustrates the Format Data Series/Options window for a 3-D chart along with a sketch defining the respective terms. Figure 3.26 shows variations of a 3-D chart for the same simple data set as before. In Figure 3.26a the default chart corresponds to the Format Data Series window in Figure 3.25. In Figure 3.26b the gap width has been increased, which produces a corresponding narrowing of the column widths (overall chart width remains constant). In Figure 3.26c the chart depth has been increased, producing a corresponding increase in the depth of the columns. Finally, in Figure 3.26d the gap depth has been increased, and this action results in a thinning of the individual column depths. Of course, a combination of all three adjustments may be made to achieve the desired final presentation.

7326_C003.fm Page 56 Tuesday, March 7, 2006 6:17 AM

56

What Every Engineer Should Know About Excel

FIGURE 3.24

The default chart shown in the window of Figure 3.25 includes shading fill applied to the wall and floor backgrounds for the columns. These fills have been removed in the displays of Figure 3.26 to show the column spacing more clearly, but may be retained or modified as needed.

3.20 Chart Format and Cosmetics Most of the charts prepared for engineering purposes will have a rather simple format involving minimal artistic or cosmetic effects. In addition, most charts and graphs will be duplicated in black and white for economy reasons, and color will not be a factor. For

7326_C003.fm Page 57 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

57

FIGURE 3.25

visual presentations, color is certainly used to advantage. Excel does offer the opportunity to adjust chart fills, fonts, colors, line size, and other effects. Some cosmetic effects involving G & A charts have already been illustrated in Section 3.15. The combination of charts and embedded drawing objects will be discussed in Section 4.2 and Section 4.6, and the use of the Drawing toolbar is illustrated at that point. The purpose of this section is to illustrate the format windows that may be called forth to make adjustments in various chart styles and appearance. Figure 3.27a shows a very simple type 5 (Section 3.3) scatter chart with a gray fill in the plot area as obtained in the default setting. The main elements of the chart style that may be varied are Chart Area,

7326_C003.fm Page 58 Tuesday, March 7, 2006 6:17 AM

58

What Every Engineer Should Know About Excel

FIGURE 3.26

Plot Area, Either Axis, Data Series, and Gridlines. The format process is initiated by doubleclicking one of these elements and thereby calling up one of the format windows shown in Figure 3.27b through Figure 3.27f. The adjustments are then made as desired. Obviously, a very large array of choices is available. It should be noted that Fill Color for either the chart area or plot area may also be changed by using a single click followed by adjustment in the Fill Color box on the Drawing toolbar.

3.21 Surface Charts Surface charts of the wire mesh or color variation type may be plotted by clicking Surface Chart on Chart Wizard. The adjustment of the chart depth (see Section 3.19) is somewhat problematical, but may be accomplished with the following procedure: 1. 2. 3. 4. 5. 6. 7. 8.

Select (activate) the data. On Chart Wizard choose Area Chart, 3-D effect. Double-click Axis in Depth dimension. Click FORMAT/SELECTED DATA SERIES/OPTIONS. Make adjustments to the chart depth as desired. Activate the chart (if not already activated). Click CHART/CHART TYPE. Select Surface Chart with either surface continuous or wire mesh options. The 3-D chart will now appear with the adjusted depth dimension. Repeat the procedure until the desired proportions are obtained.

Figure 3.28 shows a wire mesh surface chart for the Bessel functions of Section 3.13.

7326_C003.fm Page 59 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

59

FIGURE 3.27

3.22 Suggested Scatter Graph Setting as Default Chart Because scatter graphs are often used in engineering work, the reader may find it convenient to choose the format and cosmetics of such a graph as the default setting for plotting data. The following procedure may be used to establish a type 5 scatter chart as the default setting with (1) black lines for all data series, (2) solid black symbols for all data markers, and (3) white fill for the plot area. Black-and-white settings are chosen because they are most often used for duplication of reports, etc. If colors are needed, they may be added later. The following procedure sets up a chart that displays five data series in the foregoing format. It will automatically adjust for fewer data series or for other types of scatter graphs.

7326_C003.fm Page 60 Tuesday, March 7, 2006 6:17 AM

60

FIGURE 3.27 (continued)

What Every Engineer Should Know About Excel

7326_C003.fm Page 61 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

FIGURE 3.27 (continued)

61

7326_C003.fm Page 62 Tuesday, March 7, 2006 6:17 AM

62

What Every Engineer Should Know About Excel

1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6

FIGURE 3.28

1 2 3 4 5 6 7 8 9 10

A x

B y 1 2 3 4

C z 2 3 4 5

D t 3 4 5 6

E a 4 5 6 7

F b 5 6 7 8

G 6 7 8 9

H

I

J

K

10 8

y z t a b

6 4 2 0 0

2

x

4

6

FIGURE 3.29

1. Enter the simple data set for x, y, z, t, a, and b as shown in Figure 3.29. 2. Select (activate) all the data and click Chart Wizard. 3. Select a type 5 scatter chart to produce the result shown in Figure 3.29. Note the gray fill for the plot area. Colors will appear for the different data series. Do not bother with chart proportions. 4. Click each data series, followed by FORMAT/DATA SERIES/select black as the color for both line and markers, then click OK.

7326_C003.fm Page 63 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

63

5. Click to activate the plot area. Then click FORMAT/FORMAT PLOT AREA/click the white color box, then click OK. 6. Click to activate the entire chart area. Then click CHART/CHART TYPE/CUSTOM TYPE/Set as default chart. Name the custom setting as desired. This default setting will allow for five sets of data series with black lines and data markers. If other series are added they will appear in color and must be formatted accordingly. If types 1, 2, 3, or 4 scatter graphs are chosen for data presentation, they will also appear with black lines and data markers. If column, bar, area, or surface charts are selected for data presentation, they will be unaffected by this default setting.

3.23 An Exercise in 3-D Visualization This example gives the reader an opportunity to exercise his or her space visualization capabilities. Consider the set of 12 wire frame 3-D views of the object shown in Figure 3.23. The chart in the upper-left corner is the same as that of Figure 3.28. These objects are displayed at different rotation and elevation positions using the methods described in Section 3.13. Before going further, the reader may want to examine each of these views and try to visualize their relative positions. The 12 views are not all drawn to exactly the same scale. Some stretching has been employed to alleviate excessive compression of the wire frame elements. Recall from the discussion of Section 3.13 that a rotation angle of 0° or 360° represents a view head-on or straight into the page. An elevation angle of 0° represents the same viewing position. An elevation angle of +90° represents a view straight down on the top of the object, whereas an elevation angle of −90° represents a view straight into the bottom of the object. With this in mind, the display of 12 views is presented in Figure 3.30 along with designations of their corresponding rotation and elevation angles. Visualizing the different object positions of Figure 3.30 without the elevation and rotation information is not an easy task and represents some difficulty for most readers. This example does illustrate once again the display capabilities of Excel that were previously described in Section 3.18 and Section 3.21.

3.24 Editing Excel Charts Using Word The combination of symbols and line drawings with charts is discussed in Section 4.2 and Section 4.3. At this point we indicate a procedure for editing Excel charts when symbols and subscripts are needed. The suggested keyboard setup of Section 2.3 is very helpful in this regard. First, create the chart in Excel. Add all necessary text boxes, modify fonts and formats on axes, etc., as desired. Adjust chart proportions. If you are satisfied with the format, there is no need to go further. If special symbols are needed that are easier to create in Word, use the following procedure:

1

S1

1

S4

FIGURE 3.30

S5

S3

E(-26), R(319)

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

1

S1 S2

E(-40), R(49) 1

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

S4

S5

E(-40), R(139)

-0.6

-0.6

-0.4

-0.2

0

0.2

-0.5

0

0.4

1

0.6

E(64), R(319)

E

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

E(-40), R(139)

0.5

0.8

1

1

E= Elevation, R = Rotation

S3

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

-0.2 -0.4

-0.5

0

0.5

E(-66), R(39)

5

E(40), R(139)

1

0

-0.5

0.5

-0.5

0

0.5

1

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

E(60), R(49)

E(-56), R(329)

64

S2

E(19), R(139) 0.8

-0.4 0

0.4 0.2

-0.2

-0.6

0.6

0.8

1

E(24), R(329)

0

0.2

0.4

0.6

0.8

E(14), R(39)

7326_C003.fm Page 64 Tuesday, March 7, 2006 6:17 AM

What Every Engineer Should Know About Excel

7326_C003.fm Page 65 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

65

1. Copy the chart to a new Word document by the following procedure: a. Activate the chart area (cells), including the text boxes. Click EDIT/COPY. b. Open a new Word document. c. Click EDIT/PASTE SPECIAL/PICTURE (ENHANCED METAFILE). Do not click Excel Object. 2. Adjust the size of the picture with FORMAT/PICTURE/SIZE. 3. Deactivate the chart (picture) and then double-click Picture. A new window will appear with areas available for editing enclosed by dashed lines. An example of an unedited chart is shown in Figure 3.31a. The window for editing the picture is shown in Figure 3.31c, and the result of the editing process is shown in Figure 3.31b. The edited items in this example are: a. The scale notation is changed to powers of 10, i.e., 105 instead of 100,000. b. The definition of y is added to the y-axis label and oriented vertically by clicking FORMAT/TEXT DIRECTION/VERTICAL. c. Uppercase R is changed to lowercase r. d. The definition of x is added to the x-axis label, including the Greek symbol μ. e. A text box is added in the center of the figure, including a Greek symbol. Note that various chart elements, including gridlines, borders, text boxes, labels, etc., may be activated by clicking and edited as desired. In addition, the elements (even individual gridlines) may be moved in position with the arrow keys or nudged as described in Section 2.6 by pressing Ctrl in combination with the arrow keys. The font is edited by clicking FORMAT/FONT. Text alignment (horizontal or vertical) is edited by clicking FORMAT/TEXT DIRECTION. 4. When the editing process is complete, click Close Picture at the upper-left corner of the editing window. The edited chart will appear in the Word document. Position and size are adjusted as desired. The text and text box will size and move with chart. 5. If needed, copy the chart back to the Excel workbook as a Picture (Enhanced Metafile).

3.25 Editing Excel Tables Using Word The procedure is the same as that followed in the previous section for editing charts, except that the cell area copied to Word is the area occupied by the table. Figure 3.32 illustrates the results applied to a simple table. The table is created in Excel as shown in Figure 3.32a. The cell area A1:D6 is copied to Word as a Picture (Enhanced Metafile). The picture is deactivated in Word and then double clicked producing the screen image shown in Figure 3.32b. The result of the editing process is shown in Figure 3.32c: Δploss/(p1 – p2) replaces dploss/(p1 − p2), β replaces b, and α replaces a. In addition, the line below Squareedged and Flow is clicked and then deleted. As in the case of graphs, the keyboard setup of Section 2.3 is used to advantage.

7326_C003.fm Page 66 Tuesday, March 7, 2006 6:17 AM

66

What Every Engineer Should Know About Excel

1000

0.6594

y = 0.1104x 2 R = 0.9778 y

100

10 10000

100000

x (a)

10 3

y = Nu/Pr 0.4

y = 0.1104x

0.6594

r 2 = 0.9778 10 2 u md/ μ > 3000

Forced Convection in Tube,

10 10 4

x = Reynolds Number, Re =

(b) FIGURE 3.31

umd/μ

10 5

7326_C003.fm Page 67 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

FIGURE 3.31 (continued)

67

(c)

3.26 Alternate Procedure In some cases the double-click procedure mentioned before does not produce the chart or table ready for editing as shown in Figure 3.31c. In that event, the chart may be “ungrouped” by activating the chart followed by clicking DRAW/UNGROUP on the Drawing toolbar after the figure has been copied to Word as a Picture (Enhanced Metafile). The result of such action with Figure 3.29, the subject for editing, is shown in Figure 3.33. In Figure 3.33a, we have the original figure without the gray fill. The screen dump in Figure 3.33b shows the result of ungrouping. Everything is activated as individual items. Editing is accomplished as described, by clicking the individual items. Four edits are shown in Figure 3.34. In Figure 3.34a “text” has been replaced with αβγδ in the text box. In Figure 3.34b the width of the first line segment of the bottom data series has been increased and the end data markers opened. In Figure 3.34c the abscissa label has been changed. In Figure 3.34d the border of the plot area is widened, one horizontal gridline

7326_C003.fm Page 68 Tuesday, March 7, 2006 6:17 AM

68

What Every Engineer Should Know About Excel

1 2 3 4 5 6

A

B

b 0.4 0.5 0.6

Square-edged orifice 0.86 0.78 0.67

dploss/(p1-p2) Flow Venturi nozzle a=7 0.8 0.1 0.7 0.1 0.55 0.1

(a)

(b)

Square-edged orifice 0.4 0.86 0.5 0.78 0.6 0.67

ploss /(p 1 – p 2) Flow Venturi nozzle =7 0.8 0.1 0.7 0.1 0.5 .1 (c)

FIGURE 3.32

7326_C003.fm Page 69 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

69

10 8 6

y z

4

t

2

a

text

b

0 0

2

x

4

6

(a)

(b) FIGURE 3.33

is widened, and two of the scale markings of the abscissa are increased in size — admittedly an odd modification, but illustrative of the individual editing choices available. Note again that there is no need to engage Word in the editing process unless symbols and subscripts or superscripts are involved.

3.27 Editing Excel Charts Directly in Word by Using Grouping If fine details of editing are not needed for an Excel chart, but only combined math–symbol–text additions or modifications, the chart may be copied to Word as an Excel worksheet object. Double-clicking the chart in Word will then enable editing using all the features of Excel while still in Word. Additions or substitutions of math symbols for regular text coordinate labels may be accomplished with text boxes and deletion of the original Excel labels.

7326_C003.fm Page 70 Tuesday, March 7, 2006 6:17 AM

70

What Every Engineer Should Know About Excel

10 8

y z t a b

6 4 2 0 0

2

4

x

6

(a) 10 8

y z t a b

6 4 text

2 0 0

2

4

x

6

(b) 10 8

y z t a b

6 4 text

2 0 0

2

f( )d (c)

4

6

10 8

y z t a b

6 4 text

2 0

0

2

4

x

6

(d) FIGURE 3.34

Figure 3.35 gives an example of such editing. The scatter graph of Figure 3.21 is copied to a Word document as an Excel Chart Object using Paste Special. Double-clicking Picture in Word produces the screen shown in Figure 3.35a, with the “x” label activated. In the screen in Figure 3.35b, a text box has been added with αβ∫e−axdx in 16 point type. The border and fill of the text box are then removed along with the border for the original chart area. The resulting text box and chart are then grouped by the following procedure:

7326_C003.fm Page 71 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

71

(a)

(b)

e-axdx

10 8 6

y

4

z t

2

a

0 0

1

2

(c) FIGURE 3.35

x

3

4

b

7326_C003.fm Page 72 Tuesday, March 7, 2006 6:17 AM

72

What Every Engineer Should Know About Excel 1. While holding down the Shift button, the text box and chart are both activated. 2. Still holding down the Shift button, DRAW/GROUP on the Drawing toolbar is clicked, as indicated in Figure 3.35b.

The final chart is shown in Figure 3.35c. The combination chart and text box will now move as one entity. To ungroup, activate the combination and click DRAW/UNGROUP.

Problems 3.1

The following data are collected in a certain experiment: x

y

24,461 28,257 49,912 63,900 70,557 79,356 95,091 102,095 107,346 108,480

71.9 90.3 126.9 149.1 162 169 204 214 199.4 202.6

Plot the data as types 1, 2, and 5 scatter charts using linear, semilog and log–log coordinates. Based on these plots, obtain a suitable correlation for the data. Include the correlation equation and value of R2 on each plot. 3.2

The following additional data are collected for the experiment of Problem 3.1. Add to the original data and obtain a new correlation for the complete set of data. x 18,000 201,000 65,230 98,750

y 61 352 175 182

7326_C003.fm Page 73 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs 3.3

73

Plot the following data on a suitable scatter chart and obtain a trendline that best fits the data. Include the trendline and value of R2 on the chart. x

y

0.2 0.5 1.2 2.4 3.1 4.6 5.1 6.9

0.1 0.3 1.5 5.9 8.9 21.2 24.9 42.6

3.4

Interchange the columns in Problem 3.1, Problem 3.2, and Problem 3.3 and replot the data with y as the abscissa. Subsequently, obtain new correlation and trendline equations.

3.5

Two sets of variables are measured as functions of x and tabulated as follows: x

0

2

4

6

8

10

12

y1 y2

0.8 1

0.7 2

0.6 3

0.5 4

0.4 5

0.2 6

0 7

Plot the data on a type 5 scatter graph using (a) the same scale for y1 and y2, (b) an expanded scale for y1, and (c) an expanded and inverted scale for y1. 3.6

Plot the data of Problem 3.5 as (a) a column chart and (b) a bar chart.

3.7

Plot the data of Problem 3.5 as a surface chart with (a) variable surface color and (b) as a wire mesh chart. Adjust chart depth as described in Section 3.21.

3.8

Using the data table command described in Section 3.17 construct a table of the function y = e−0.1x × sin(nx) for n = 1, 2, and 3 and 0 < x < π. Select the increments in x as appropriate. Plot the function as (a) an area chart with 3-D, (b) a surface chart with variable colors, and (c) a 3-D wire mesh chart. Make adjustments in chart depth as described in Section 3.21.

7326_C003.fm Page 74 Tuesday, March 7, 2006 6:17 AM

74 3.9

What Every Engineer Should Know About Excel The following data are collected in an experiment: x 4000 5000 6000 7000 8000 9000 10,000 20,000 30,000 40,000

y 27 42 38 50 45 50 49 92 120 115

Plot these data as types 1, 2, and 5 scatter graphs on linear coordinates. What do you conclude? Select the most appropriate of these plots and obtain linear, exponential, second-order polynomial, and power correlations of the data. Display the trendline and value of R2 for each correlation. Depending on the results of these correlations, replot the data on semilog or log–log coordinates to improve the data display. 3.10 Reconstruct the data of Figure 3.16 using the data table command of Section 3.17. Then plot the results as (a) an area chart with 3-D, (b) a surface chart with variable color, and (c) a 3-D wire mesh chart. Adjust the chart depth as described in Section 3.21. 3.11 For a spectacular result, add the following fill effects to any of the charts obtained in the previous problems: a. Fill the chart area with Fill Effects/Gradient/Colors — Preset — Rainbow/ Shading styles — Horizontal. b. Fill the plot area with Fill Effects/Colors — One color/Shading styles — Diagonal down. 3.12 A certain common stock has the following price history: Period 1 2 3 4 5 6 7 8 9 10 11

Price 8.5 14 19 22 22 17 22 24 38 50 48

7326_C003.fm Page 75 Tuesday, March 7, 2006 6:17 AM

Charts and Graphs

75

Plot the stock price as a function of period. Subsequently, construct moving averages for the stock price having intervals of 2, 3, and 4 periods. Also, plot the standard error for each of the moving averages. Comment on the results. 3.13 The following results are calculated from a known analytical relationship: x

y

1 2 3 4 5 6

6 16 35 58 85 122

Choose an appropriate scatter graph for plotting y as a function of x. Then replot with y as a function of 1/x. Select coordinate systems appropriate to the tabular values. 3.14 Plot the stock price data of Problem 3.12 as a column chart. Repeat for different gap widths and overlaps. 3.15 The following data are expected to follow a quadratic relationship. Investigate this expectation with an appropriate scatter chart and second-degree polynomial trendline fit. x 0.1 1 10 100 1000

y 3.667 3.724 4.223 7.247 17.02

A quadratic function will plot as a straight line on linear coordinates when the ratio (y – y1)/(x – x1) is plotted against x. Taking the second data set (1,3.724) for the x1 and y1 coordinates, make such a plot and obtain a linear trendline fit to the data. How does this result compare with that obtained using the second-degree polynomial fit for the original data set?

7326_C003.fm Page 76 Tuesday, March 7, 2006 6:17 AM

7326_C004.fm Page 77 Tuesday, March 7, 2006 6:18 AM

4 Line Drawings and Embedded Objects in Excel

4.1

Introduction

In Chapter 3 we have seen how it is possible to generate a variety of graphical displays in Excel, which may be employed for data presentation or calculation of results. The drawing capabilities of Excel offer further opportunities for display of related schematic drawings or other information along with worksheet results and data manipulations. Although the drawing capabilities in Excel are not as extensive as in certain CAD software, they are quite versatile and offer the convenience of embedding in Word texts or Excel worksheets. For those readers who use Microsoft PowerPoint, the drawing capabilities are even more useful. Engineering schematics or drawings frequently involve the use of Greek or math symbols. The use of these symbols is a bit problematical in Excel, but we will present methods for generating graph coordinate labels and embedded text that are quite satisfactory. Examples and exercises in applications of the various segments of the Drawing toolbar will be given to enable the reader to attain some facility with these elements. The reader can then expand the use as his or her need dictates.

4.2

Constructing, Moving, and Inserting Straight Line Drawings

1. Open a new worksheet. Display the Drawing toolbar. 2. On the Drawing toolbar, click AutoShapes/Lines/Freeform. 3. Holding down the Shift key, click the crosshair at a point to start straight lines, quickly release-click, then move the crosshair to the next point and click again; repeat until the end of the drawing is reached, and then double-click. If the end is at a closed figure, right-click. Several line elements may be drawn separately to form the final drawing object, in which case multiple applications of the AutoShapes/Lines/Freeform clicking process must be performed. Line weight or style (including shading) may be adjusted by clicking the Line Style button on the Drawing toolbar. The Excel worksheet grid may be used to guide the drawing process. Depending on the size of drawing needed, it may be advantageous to work with a reduced or compressed worksheet grid by clicking VIEW/ZOOM/percent reduction. Reducing the column width with FORMAT/COLUMN/specify width may also help drawing precision. The row height may also be reduced to provide a finer 77

7326_C004.fm Page 78 Tuesday, March 7, 2006 6:18 AM

78

What Every Engineer Should Know About Excel

4.

5.

6. 7.

8.

4.2.1

drawing grid. Drawing pieces may be constructed separately and then dragged together to assemble an overall drawing object. See “grouping” under Excel Help/ Index. Precise movements of objects may be accomplished by activating the object and holding down the Ctrl button while pressing arrow buttons for the desired direction. Callout boxes (from AutoShapes) may be used to add nomenclature, as well as text boxes, with or without arrows. Line borders of text boxes may be removed by clicking the Line Color button on the Drawing toolbar and then selecting No Line. To avoid overlap of worksheet or graph gridlines, the text box may be filled with white color. When math symbols or superscripts or subscripts are to be used in text boxes or nomenclature, it will be easiest to transfer or create the drawing object in an open Word document before adding these elements. Drawing objects with all annotations may be moved, copied, or inserted elsewhere by highlighting (selecting/dragging) the cells containing the object and then clicking EDIT/COPY. The target document is then opened, the desired location clicked/selected (upper-left cell for the location on an Excel worksheet) and then click EDIT/PASTE or EDIT/PASTE SPECIAL. The original drawing may be enlarged or compressed for a separate printout by using the percentage dialog box in FILE/PAGE SETUP. When the drawing is to be pasted onto another Excel worksheet, it can be drawn to fit the anticipated space allocation in the target worksheet by using the same row/column/cell proportions during the drawing process. Cosmetic features may be added.

Drawing Line Segments in Precise Angular Increments

To draw an unwavering straight line segment (not freeform objects) in increments of 15° (or precisely horizontal or vertical) click the Line icon (Figure 4.3) on the Drawing toolbar. Then, while holding down the Shift key, click at the starting point, hold down the button, and move to the end location to draw the line. When the Shift key is not depressed, the line may be drawn in any direction. This is very useful for drawing precise horizontal or vertical lines.

Example 4.1: Assortment of Drawing Shapes Figure 4.1 shows a collection of different drawing shapes that may be constructed using the Draw and Drawing toolbar functions of Excel. The following remarks refer to the objects at the noted cell locations for items in which the construction is not obvious or already noted on the worksheet. K6:P10 — The donut shape is changed to a hollow cylinder using the 3-D effects tool, which allows variation in length. A gradient pattern fill is then added. R4:R25 — A resistor shape is first drawn using the AutoShapes/Freeform lines tool (see discussion in Section 4.2, step 3) and then copied several times with an assortment of line weights (as noted). It is also compressed by dragging. L20:M24 — A rectangle shape is drawn first. 3-D effects are added, and then a fill pattern with gradient effect is used.

7326_C004.fm Page 79 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel

79

FIGURE 4.1

P15:P23 — Two circles are drawn and then filled with gradient patterns from innerto-outer and outer-to-inner. N24:P33 — A rectangle is drawn with 3-D and light fill applied. A resistor element is added along with arrows and straight lines. The elements are grouped (combined to form one object) and then rotated. R28:S37 — If needed, a digitized photo can be added. This is a digital photo taken with a digital camera and transferred to the worksheet. Editing of brightness, contrast, cropping, and image size may be accomplished before transfer to the worksheet. Editing can also be performed after transfer to the worksheet by activating the photo and then clicking VIEW/TOOLBARS/PICTURE. The Picture toolbar will then appear. Of course, the figure may also be presented without the presence of gridlines and column and row headings.

Example 4.2: Construction, Assembly, and Labeling of a Line Drawing An illustration of the mechanisms of an assembly of line drawings in Excel along with nomenclature in Word is shown in Figure 4.2: 1. In Figure 4.2a, a shell of a solar absorber is drawn with AutoShapes/Lines/Free form as described previously.

7326_C004.fm Page 80 Tuesday, March 7, 2006 6:18 AM

80

What Every Engineer Should Know About Excel

25% patternfill

5% pattern fill

T3 = Radiation temperature (q/A) solar

Glass cover

T2

h, T Black absorber

keff

x

T1 (q/A) Load

Solar Absorber (Collector)

FIGURE 4.2

2. Next, the inner boundary is drawn in Figure 4.2b and added to Figure 4.2a to produce the combination shown in Figure 4.2c. In practice, the two elements would not be moved around as shown here. The drawings are copied to show the steps as they progress. 3. A 5% pattern fill is added to the inner boundary as shown in Figure 4.2d. This represents the air inside the collector. 4. A long thin rectangle is drawn in Figure 4.2e and filled with a 25% pattern fill. The dimensions of the rectangle are squeezed, adjusted, and moved to the top of the shell as shown in Figure 4.2f. This element represents the glass cover of the solar collector. 5. A 4 1/2 pt black line is added in Figure 4.2g to indicate the black absorbing surface of the bottom of the solar collector.

7326_C004.fm Page 81 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel

81

6. The elements of the assembled drawing are then grouped by (1) holding down Shift, (2) clicking on the elements in sequence, and (3) clicking Draw/Group. The assembled object may now be moved or copied as a single object. In Figure 4.2i, it has been rotated by either clicking Draw/Rotate or clicking the Rotate icon and dragging to the desired angle. 7. The assembled drawing is then copied to a Word page in which nomenclature is added with subscripts and appropriate symbols. It may either be used in the Word document or copied to an Excel worksheet as was done here. The final diagram is shown in Figure 4.2h. The printout shown here is without gridlines or column and row headings. The gridlines are useful when constructing the drawing elements.

Example 4.3: Practice Exercises with the Drawing Toolbar A familiarization with the Drawing toolbar shown in Figure 4.3 may be accomplished by carrying out the following exercises, which refer to the drawing objects shown in Figure 4.1 and Figure 4.2. The solar absorber in Figure 4.2 is considered first: For Figure 4.2a, click AutoShapes (fourth icon from the left on Drawing Toolbar), then Lines, and then Freeform (bottom row, center of six icons). Hold down the Shift key, move the crosshair to the desired starting point (a corner of a cell), click quickly, and release the mouse button. Move the crosshair to the next corner, click quickly, and continue until five segments (two top lips, two sides, and a bottom segment) are in place. Double-click at the last point. For Figure 4.2b, perform the same operation as that of Figure 4.2a, except that only three line segments are required. Line up the drawing using a worksheet grid to obtain the dimensions in Figure 4.2b. For Figure 4.2c, activate the drawing in Figure 4.2b and drag-move to match with Figure 4.2a as shown in Figure 4.2c. Once the drawings are assembled, activate Figure 4.2b — click until boundary handles appear. Then click the Fill icon (eighth from the right on the Drawing toolbar). Select Fill Effects and then the Pattern tab. The 5% fill is the block in the upper-left corner. Click this corner, and then OK. Fill will appear as in Figure 4.2d.

FIGURE 4.3

7326_C004.fm Page 82 Tuesday, March 7, 2006 6:18 AM

82

What Every Engineer Should Know About Excel

For Figure 4.2e, click on the rectangle icon (seventh from the left on the Drawing toolbar) and move-drag the crosshair while holding down the mouse button to create a rectangle. Release the mouse button when the desired shape is attained. Do not worry if the rectangle is not the exact size or proportion needed. That will be taken care of later. Next click on the Fill icon, Fill Effects, and then select Patterns and the fourth box in the left column for 25% fill. Click OK, and the rectangle will appear as in Figure 4.2e. Drag the filled rectangle to a position on top of the drawing in Figure 4.2d. Then drag, squeeze, or stretch to the slim dimensions shown by positioning the doublearrow pointer on the side handles of the filled rectangle by holding down the mouse button and dragging until the two figures line up. Nudge it into exact position using the Ctrl button in conjunction with the arrow keys. Next, draw a straight line at the inside bottom of the collector using AutoShapes/ Lines/Freeform as in Figure 4.2a and Figure 4.2b. Click the Line Style icon (fifth from the right on the Drawing toolbar) and select the 4 1/2 pt line. Group the drawing elements created earlier by holding down the Shift key and clicking in sequence the four elements (a, b, e, and 4 1/2 pt line). Then click Draw (the left icon on the Drawing toolbar) and select Group at the top of the palette. The composite object may now be moved as a single entity. At this point the composite figure may be copied to an open Word document by activating the object and then clicking EDIT/COPY. Open a Word document sheet and click EDIT/PASTE to paste the composite figure. The nomenclature elements are added by using either text boxes or callout arrows (as for T1 and T2) that are called from the Drawing toolbar in Word using AutoShapes/Block Arrows/select a callout arrow icon. Note that subscripts or math symbols are typed in conventional Word fashion (see Section 2.3). After the nomenclature is added, the composite drawing is copied back to the Excel worksheet, where it appears as shown in Figure 4.2h. Rotation of the object may be performed by activating the object and either clicking Draw/Rotate or Flip, or by clicking the Rotate icon (third from the left on the Drawing toolbar). The following exercises refer to some of the drawing objects shown in Figure 4.1: 1. Create circles as shown in the figure at P16. Click on the Ellipse icon (eighth from the left on the Drawing toolbar). Holding down the Shift key, create a circle by moving the crosshair until the desired size is accomplished. While the circle is still activated (handles appearing), click the Fill icon and then Fill Effects. Click Shading Styles/From Center/ then select the right-hand Variant (dark center). Click OK. The circle at P21 is formed using the left Variant (dark edge). The degree of shading may be adjusted with the Dark to Light slider. 2. Create donut shapes at K2:M10. Use AutoShapes/Basic Shapes/Donut. Drag the yellow dot to achieve the desired size. 3. Create the hollow cylinder, as shown, at N9 by first creating a donut. Then click the 3-D icon (first icon on the right of the Drawing toolbar) and choose the lowerleft icon (or others if you prefer.) Click 3-D settings, then the sixth icon from the left, and then the desired length to change the length of the cylinder. To accomplish

7326_C004.fm Page 83 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel

83

the shading, activate the object, click Fill icon/Fill Effects/Gradient/Shading Styles/Horizontal/Variants as desired, and then click OK. 4. Create arcs at A19 using AutoShapes/Basic Shapes/Arc. Then repeat while holding down the Shift key. Note that circular arcs are created. Note the effect of dragging the yellow dot. 5. The resistor elements at R5:S25 are created by (1) using AutoShapes/Lines/Freeform to construct a single resistor, (2) copying the resistor to rows 7, 10, 12, and 15, (3) changing the line width of each copied resistor, (4) copying and compressing (by dragging handles) the resistor to R17, and (5) subsequently copying the compressed resistor to R19, R21, R23, and R25. The line weights of these last resistors are also modified as indicated. If all of these exercises are performed, a person should attain a reasonable facility with use of the Drawing toolbar. Of course, further experimentation is encouraged.

4.3

Inserting Items in Excel with Symbols, Subscripts, and Superscripts

It is possible to use symbols (Greek, math, or any other) in an Excel worksheet by calling up the symbol font. When used as a column heading or as a variable name, the characters will not transfer as symbols to the coordinates of a graph. The same restriction applies for superscripts and subscripts in mathematical formulas or other terms that might be used on a graph. Equations and text with symbols may be typed in Word and copied to Excel worksheets or graphs as Word documents, but the result is a block one page wide that obscures information on the worksheet below the block. Such a copying procedure is quite acceptable for inserting documentation remarks pertaining to a spreadsheet program, but is not satisfactory for titles of figures or axis labels. A text box created in Word may also be copied to Excel as a Word document, but any symbols contained therein will be lost. The solution to the problem is to create the item, equation, or text in Word using whatever format is desired and then to copy it to Excel as a Picture (Enhanced Metafile) object. A possible procedure is as follows: 1. Create the item, equation, title, or object in Word, using symbols, superscript, and subscript notations as needed. Single or multiple columns may be used in the format, depending on the style and appearance desired. Several objects may be created at one time on a single sheet for subsequent transfer to an Excel worksheet or graph. In Word, it is possible to create a text box that allows rotation of text or symbols inside the box into a vertical position. This may be the desired format for the label of a vertical axis on a graph. The procedure is as follows: a. Open the Drawing toolbar in Word by clicking VIEW/TOOLBARS/DRAWING. b. Click on Text Box. c. Anticipate the size of the text box needed and click and drag to set the size. d. Enter text or symbols in the box. Open the Text Box toolbar with VIEW/ TOOLBARS/TEXT BOX.

7326_C004.fm Page 84 Tuesday, March 7, 2006 6:18 AM

84

What Every Engineer Should Know About Excel

FIGURE 4.4

2.

3. 4. 5. 6.

7.

e. In the Text Box toolbar dialog box (far right) click to rotate the text into the desired position. An alternate procedure is to activate the text box and then click FORMAT/TEXT DIRECTION/select desired alignment of text. f. Adjust the final size of the text box to the desired proportions. To remove the line border around the text box, click the Line Color icon in the Drawing toolbar and then select No Line. Save the Word document with an appropriate name and close. Create the Excel worksheet or graph, leaving blank the column title, axis title, or whatever nomenclature you may wish to fill with a copied item from Word. Save the workbook with an appropriate title. Return to the saved Word document. Select the item in Word to be copied to Excel by clicking and/or dragging. Click EDIT/COPY. Reopen the Excel workbook. If the item is to be inserted on a worksheet, click the cell where it is to be inserted. If it is to be inserted on an embedded graph in a worksheet, click on an open cell nearby. Click EDIT/PASTE SPECIAL/Picture (Enhanced Metafile). Do not choose Microsoft Word Document Object. The item will appear at the clicked location on the worksheet.

7326_C004.fm Page 85 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel

85

8. Click or drag the item to the exact location desired on the graph or worksheet. Check the final style and location with FILE/PRINT PREVIEW. Modify as needed. 9. If the item is to be inserted on a separate graph sheet, activate the graph, and follow the same PASTE SPECIAL procedure as mentioned earlier. In this case, the item will appear at the upper-left corner of the graph. Click or drag the item to the final position desired. 10. Repeat the procedure for as many items as required. If there are no symbols required in the Excel sheets, there is no need to involve Word at all. The editing applications can all be accomplished on the Excel sheet. In Word it is possible to set up the keyboard using shortcut keys for symbols so that the time-consuming INSERT/SYMBOL process for each symbol is avoided (see Section 2.3). For some graphics and drawing objects, a preferable procedure may be to (1) create the graphic or object in Excel, (2) COPY/PASTE to Word as an Excel worksheet, (3) perform editing involving symbols, subscripts, etc. in Word, and then (4) COPY/PASTE SPECIAL back to Excel (or to a Word document) as Picture (Enhanced Metafile). If transferred to an Excel worksheet, the graphic or object may then be moved, compressed, or expanded as needed.

4.4

Inserting Equations or Symbols in Word Using Equation Editor

This is achieved by the following procedure: 1. Designate the location for an insert. See Figure 4.4. 2. Click INSERT/OBJECT/remove the check from Float Over Text, then click Microsoft Equation 3.0 followed by OK. This action will result in a fixed location of the symbol or equation, i.e., one that may not be dragged to other positions. 3. Proceed with use of Equation Editor for constructing either complete equations or symbols. 4. Click FILE, move the cursor away from File Menu, and click again. The equation or symbol will be fixed in the designated position. 5. If the object is to be used for nomenclature on a table or chart, dragging or nudging to the exact position may be needed. In this case, the Float Over Text check mark should be left intact in step 2. It will not be possible to produce a lineup with text as shown in the following example when the “float” position is in effect. The example shows the insert of a summation sign with limits of i = 2 and i = n − 1 into an equation at the point indicated by the arrow. The summation symbol is called by clicking on the point indicated in the Equation Editor window. Area = [y1 + yn + yi/2]Δx i= n −1

Area = [y1 + yn +

∑ i=2

yi/2]Δx

7326_C004.fm Page 86 Tuesday, March 7, 2006 6:18 AM

86

4.5

What Every Engineer Should Know About Excel

Inserting Equations and Symbols in Excel Using Equation Editor

This is achieved as follows: 1. Select cell for location of Equation. 2. Click INSERT/OBJECT/Microsoft Equation 3.0/OK. 3. Before starting construction of an equation or symbol, set the size of the type by clicking SIZE/OTHER/enter desired final point size. Click OK. 4. Construct equation or symbols using features of Equation Editor. 5. When an equation or symbol has been constructed, double-click the object until it is highlighted or activated. 6. Click EDIT/CUT. 7. Click the cell or chart location for the insert. 8. Click EDIT/PASTE. The object will appear at the designated cell or at the upperleft corner of the chart. 9. Activate the object and drag to the final desired location. A box may enclose the object. Remove the line enclosing the box, if desired, by activating the object and clicking Line Color/No Line on the Drawing toolbar. 10. An empty box will appear at the cell chosen in step 1. Delete it. 11. To edit the object equation or symbol, double-click to activate it, and the Equation Editor toolbar will reappear. Edit as usual.

Example 4.4: Graphics, Symbols, and Text Combinations An example of the use of inserts and graphics composed and copied between Word and Excel is shown in Figure 4.5. In this figure, the assembly of items is printed as a worksheet with column and row headings. Of course, the gridlines and row and column headings could have been left out to give a more appealing appearance for a final presentation. Some elements of the assembly are shown at the following cell locations: A1:F12 — This is the Excel calculation of the equation at G11. The equation at G11 was written in Word and copied to the worksheet at this location. I2:M9 — This is the cavity drawing assembly. The cavity and semitransparent cover were drawn as separate objects in Excel, grouped, and copied to Word. The labels using subscripts and Greek symbols were then added in Word, and the total assembly copied back to the final Excel worksheet. B14:L41 — The graph was plotted from the Excel calculations using Chart Wizard with a type 3 x-y scatter graph chosen for the presentation (see Section 3.3). The x- and y-axis labels were composed in Word and copied to the Excel worksheet, as was the equation for K shown at G18. The labels for K = 5, 2, etc., were inserted as text boxes on the Excel worksheet. Composition in Word was not needed because no Greek symbols are involved. B44:I61 — This descriptive write-up was composed in Word and then copied to an Excel worksheet. All of the necessary compositions in Word were accomplished on a single page, so the subsequent copying process was relatively easy. The final worksheet is shown in Figure 4.5 after use of FILE/PAGE SETUP/PAGE/Scaling/Fit to 1 page wide by 1 page tall.

7326_C004.fm Page 87 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel

87

A B C D E F G H I J 1 emarea emapp(0.1) emapp(0.5) emapp(1.0) emapp(2.0) emapp(5.0) 2 0 1 1 1 1 1 3 0.1 0.5 0.833333 0.909091 0.952381 0.980392 A 2 = area of opening 4 0.2 0.333333 0.714286 0.833333 0.909091 0.961538 A1 , 1 5 0.3 0.25 0.625 0.769231 0.869565 0.943396 semitransparent cover 6 0.4 0.2 0.555556 0.714286 0.833333 0.925926 + 2 + 2 = 1.0 2 7 0.5 0.166667 0.5 0.666667 0.8 0.909091 8 0.6 0.142857 0.454545 0.625 0.769231 0.892857 0.7 0.125 0.416667 0.588235 0.740741 0.877193 9 10 0.8 0.111111 0.384615 0.555556 0.714286 0.862069 11 0.9 0.1 0.357143 0.526316 0.689655 0.847458 app /( 2 + 2 /2) = K/[(A 2 /A1 )(1 - 1) + K] 12 1 0.090909 0.333333 0.5 0.666667 0.833333 13 14 1 15 16 0.9 17 K=5 18 1 2 2 19 0.8 20 21 22 0.7 23 K=2 24 0.6 25 K=1 26 K=0.9 27 0.5 28 K=0.7 29 0.4 30 K=0.3 31 K=0.5 32 0.3 K=0.2 33 34 0.2 35 K=0.1 36 37 K=0.1 0.1 38 39 0 40 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 41 42 (A 2 /A1)(1 - 1) 43 44 Apparent Emissivity of Cavity with Partially Transparent Cover 45 46 A1 = inside area of cavity 47 A2 = area of opening 48 1 = emissivity of inside cavity surface 49 2 = emissivity of transparent cover 50 2 = transmissivity of transparent cover 51 2 + 2 + 2 = 1.0 52 Behavior Limits 53 54 55 1.0, ( 2 = 0); behaves as open cavity (Prob. 8-129) 2 56 1.0 and A 2/A 1 1.0; app 2 1 57 0 (opaque); cavity with opaque shield 2 58 0 and A 2/A 1 = 1.0; shield on flat surface 2 59 0 and 1 = 1.0; opaque shield on black surface, 2 app = 2 /2 60 app/( 2

+

2 /2)

K=

FIGURE 4.5

/(

+

/2 )

7326_C004.fm Page 88 Tuesday, March 7, 2006 6:18 AM

88

What Every Engineer Should Know About Excel

Eb3

Eb1 1/A1 F13

(1- 1)/ 1A1

2

1/A2F23 (1- 2 )

1/A1F12 (1- 2 ) Eb2 J2i /(1 -

2)

2/ 2 A2 (1- 2 )

2 / 2A 2(1- 2)

J2o /(1 -

2)

For T 3 =0, E b3 = 0, and q 1 = (E b1 – 0)/ app

R =

= 1/(A 2 R) = (

app A2 (Eb1 2+

– 0)

2/2)K/[(A 2/A1)(1 -

1) + K]

FIGURE 4.6

A network schematic is used to derive the equations is shown in Figure 4.6.

Example 4.5: Program with Embedded Text Documentation Figure 4.7 illustrates a convenient combination of Word and Excel. A program is presented at A2:D3 with variables and nomenclature at E2:F15. The documentation and description of the program was written as a Word document using Greek symbols, subscripts, and superscripts and then copied to the Excel worksheet. This combination results in a very compact presentation on a single page (if one can tolerate the small type size). A reader studying the program will find it much easier to follow than a documentation occupying several pages.

4.6

Construction of Line Drawings from Plotted Coordinates

A closed figure may be constructed in Excel by plotting a sequence of data points that returns to the initial coordinate set. An initial sketch on ordinary graph paper may form the basis for generating a smoothed line drawing when combined with the editing features of Excel graphs. We illustrate this technique with an airfoil shape. The airfoil shape has been hand-sketched on a sheet of graph paper graduated in increments of 0.1 inches. The x- and y-coordinates of the shape are then tabulated in sequence starting with the trailing edge of the airfoil, proceeding along the bottom surface of the section,

7326_C004.fm Page 89 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel

89

FIGURE 4.7

and then around the top surface back to the trailing edge. The resulting data are shown in columns A and B of Figure 4.8, with the dimensions given in inches. A type 3 scatter chart is plotted and also appears in Figure 4.8, without editing of the chart proportions. Note that the fitted computer curve for the tabulated data is not as smooth as one would expect for an airfoil section. This unevenness results from either a poor sketch (by the author) to begin with or inaccurate readings of the coordinates of the sketch. The unevenness may be smoothed by first adjusting the chart proportions to the distorted form shown in Figure 4.9, which emphasizes the imperfections in the plot. Next, the data series is activated and data points double-clicked at points along the curve that appear to need adjustment. These points are then gently dragged to new positions to smooth out the curve. Two overcorrections are shown in Figure 4.10 to illustrate the action. The results of gentle smoothing are shown in Figure 4.11. Note that the results of the smoothing (or overcorrecting) also appear in the tabulated values for x and y. Once the surface curve has been smoothed, the chart proportions are adjusted by dragging the side handles until the increments in x- and y-coordinates have the same chart measurements. The results are shown in Figure 4.12.

7326_C004.fm Page 90 Tuesday, March 7, 2006 6:18 AM

90

What Every Engineer Should Know About Excel x 8.5 7.7 6.6 5.6 4.4 3.6 2.8 2 1.1 0.85 1.2 2 2.55 3.4 4.8 6 7 7.8 8.5

y 0.9 0.8 0.7 0.65 0.5 0.5 0.45 0.55 0.8 1.25 1.7 1.9 2 1.9 1.7 1.4 1.2 1 0.9

2.5

2

1.5

1

0.5

0 0

2

4

6

8

10

6

8

10

x

FIGURE 4.9

x y 8.5 0.9 7.7 0.8 6.6 0.7 5.6 0.65 4.4 0.5 3.6 0.5 2.8 0.645 2 0.55 1.1 0.8 0.85 1.25 1.2 1.7 2 1.9 2.55 1.84 3.4 1.9 4.8 1.7 6 1.4 7 1.2 7.8 1 8.5 0.9 FIGURE 4.10

2 1.8 1.6 1.4 1.2 1 0.8 0.6 0.4 0.2 0 0

2

4 x

7326_C004.fm Page 91 Tuesday, March 7, 2006 6:18 AM

Line Drawings and Embedded Objects in Excel x y 8.5 0.9 7.7 0.8 6.6 0.7 5.6 0.59 4.4 0.5 3.6 0.5 2.8 0.5 2 0.55 1.1 0.8 0.85 1.25 1.2 1.7 1.8 1.9 2.55 1.976 3.4 1.9 4.68 1.7 6.18 1.41 7.08 1.2 7.94 1.01 8.5 0.9

91

2.5

2

1.5

1

0.5

0 0

2

4

6

8

10

x

FIGURE 4.11

x y 8.5 0.9 7.7 0.8 6.6 0.7 5.6 0.59 4.4 0.5 3.6 0.5 2.8 0.5 2 0.55 1.1 0.8 0.85 1.25 1.2 1.7 1.8 1.9 2.55 1.976 3.4 1.9 4.68 1.7 6.18 1.41 7.08 1.2 7.94 1.01 8.5 0.9

FIGURE 4.12

2.5 2 1.5 1 0.5 0 0

1

2

3

4

5

6

7

8

9

10

0

1

2

3

4

5

6

7

8

9

10

2.5 2 1.5 1 0.5 0

7326_C004.fm Page 92 Tuesday, March 7, 2006 6:18 AM

92

What Every Engineer Should Know About Excel

Problems 4.1

Plot the function y = 3.25 xe−0.1x over the range 0 < x < 5 using a type 3 scatter chart (Section 3.3) without a y-axis label. Copy the chart to a Word document and insert a vertical text box containing the aforementioned function for the label of the ordinate. Type and insert a horizontal text box containing the equation onto the chart at an appropriate position. Choose font sizes to match the size of the chart. Copy the resulting chart back to Excel using PASTE SPECIAL/PICTURE (Enhanced Metafile). Adjust the size of the resulting graph using the Format command and print out the results.

4.2

Construct the asymmetric circles shown. Then fill the areas as indicated (or with a fill pattern of your choice), and engage the 3-D effects shown.

4.3

Create the text box shown with an inserted equation. Then modify with the fill and shadow effects indicated. Note that activating the text box followed by FORMAT/TEXT DIRECTION creates the vertical text box.

4.4

Create Figure 4.6 by first creating the resistor elements as described in Section 4.3. Then create the small circles. The resistor elements may be rotated by clicking Draw/Rotate or Flip on the Drawing toolbar. Assemble the drawing in Excel and group with Draw/Group. Copy the assembled drawing to a Word document and insert all the labels using text boxes without line borders. Copy the resulting labeled drawing back to Excel as a Picture (Enhanced Metafile) and print out in several different sizes. Also, construct the equations below the diagram in Word and copy them to Excel using the same Picture format.

4.5

If you have not already done so, work through the exercises in Section 4.3

7326_C005.fm Page 93 Tuesday, March 7, 2006 6:19 AM

5 Solution of Equations

5.1

Introduction

In this chapter, we will examine the features of Excel that provide for solutions of single or simultaneous linear and nonlinear equations. Four methods will be described: (1) iterative techniques, (2) use of the Goal Seek feature, (3) use of the Solver feature, and (4) matrix inversion with the associated matrix operations. Examples will be given for each method and comments offered on the selection of the best method for a particular problem. Finally, a brief discussion will be presented on the creation of macros, along with an example.

5.2

Solutions to Single Nonlinear Equations Using Goal Seek

Nonlinear equations may be solved for real roots quite easily by using the Goal Seek feature, which is called by clicking TOOLS/GOAL SEEK. First, the equation is written in the form ƒ(x) = 0 Keeping in mind that nonlinear equations may have multiple roots, including complex ones, it may be advantageous to plot the function to get an idea of the location of the possible roots. Goal Seek uses an iterative scheme to solve the equation, and an initial guess must be provided to start the computation. A graphical display may be useful in choosing the initial guess. We consider two examples — a transcendental equation ƒ(x) = x tanx − 2 = 0

(5.1)

ƒ(x) = 3x3 − 2x2 + x − 18 = 0

(5.2)

and a cubic polynomial

The transcendental equation is plotted in Figure 5.1a using increments in x of 0.05 over the range −2 < x < +2. A visual survey of the graph indicates that there is a root at x ≈ 1.0. The worksheet in Figure 5.1b is set up with an initial guess for x inserted in cell B4 and the formula for ƒ(x) in cell B6. The guess of x = 1.0 was chosen by consulting the plot in 93

7326_C005.fm Page 94 Tuesday, March 7, 2006 6:19 AM

94

What Every Engineer Should Know About Excel

80 60 40 20 0 -2

-1.5

-1

-0.5

0

0.5

1

1.5

2

-20 -40 -60 -80 (a)

A

B

3 4 x= 1 5 6 f(x)= =B4*TAN(B4)-2 7

(b) A

B

3 4 x= 1.076845 5 6 f(x)= -0.00019 7 (c) FIGURE 5.1

Figure 5.1a. Next, TOOLS/GOAL SEEK is clicked, which produces the window in Figure 5.1d. We set cell B6 = 0 by changing (iterating) the values of x in cell B4. When OK is clicked, the window in Figure 5.1e appears along with the solution on the worksheet shown in Figure 5.1c. Because of symmetry, there is also a root at x = −1.076845.

7326_C005.fm Page 95 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

95

FIGURE 5.1 (continued)

The same procedure is followed with the cubic polynomial. A graph of the function is shown in Figure 5.2a, indicating a root at about x ≈ 2 (it turns out that the root is exactly 2.0). The worksheet is set up as shown in Figure 5.2b with an initial guess taken as x = 0. (We could have chosen x = 2.0, but that would not be as interesting.) Again, TOOLS/ GOAL SEEK is called, and the solution is shown in Figure 5.2c having a value of x = 1.99999856 ≈ 2.0. The graph for the cubic indicates that we should not expect any other real roots. Dividing the cubic by (x − 2) to extract the real root yields a quadratic function: (3x3 − 2x2 + x − 18)/(x − 2) = 3x2 + 4x +9 The roots of this quadratic are complex and have the values x = 2/3 ± 1.5986i.

5.3

Solutions to Single Nonlinear Equations Using Solver

Solver and Goal Seek offer alternate ways to solve nonlinear equations, although both employ iterative methods. A graph of the function is helpful in both instances, because it indicates a reasonable value to use as the initial guess in the iterative process. For Solver examples, we use the same nonlinear equations as used in the Goal Seek examples. In the top portion of Figure 5.3 we have the worksheet set up for the transcendental equation ƒ(x) = x tanx − 2 = 0

7326_C005.fm Page 96 Tuesday, March 7, 2006 6:19 AM

96

What Every Engineer Should Know About Excel f(x) -448 -246 -120 -52 -24 -18 -16 0 48 146 312

400

1

300 200 100

f(x)

x -5 -4 -3 -2 -1 0 1 2 3 4 5

-5

-4

-3

-2

0 -1 0 -100

1

2

3

4

5

-200 -300 -400 -500

x

(a)

A B 4 x= 0 5 6 f(x)= =3*B4^3-2*B4^2+B4-18 (b)

A B 1.99999856 4 x= 5 6 f(x)= -4.181E-05 (c) FIGURE 5.2

TOOLS/SOLVER is clicked, and the Solver Parameters window is displayed, targeting cell B4 to approach zero by changing the value of cell B3. An initial guess is listed as x = 1.0, and the solution is given in the right side of the top portion of Figure 5.3 as x = 1.0769 with a residual value of ƒ(x) = 4.3E−7. The bottom portion of Figure 5.3 gives the worksheet for the cubic equation ƒ(x) = 3x3 − 2x2 + x − 18 = 0 This time the target function is cell E4, which is to approach zero by changing the x-values in cell E3. An initial guess of x = 1 is taken, and the result is given as x = 2.00000001 with a residual value of ƒ(x) = 2.9E−7.

7326_C005.fm Page 97 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

A

97

B

A

2 3 x= 1 4 f(x)= =B3*TAN(B3)-2 5

D

E

2 3 x= 1 4 f(x)= =3*E3^3-2*E3^2+E3-18 5

FIGURE 5.3

B

C

2 3 x= 1.076874 4 f(x)= 4.29E-07 5

D

E

2 3 x= 2.00000001 4 f(x)= 2.9261E-07 5

7326_C005.fm Page 98 Tuesday, March 7, 2006 6:19 AM

98

What Every Engineer Should Know About Excel

1 =3-2*A2 2 =(7-2*A1)/5 3 FIGURE 5.4

5.4

Iterative Solutions to Simultaneous Linear Equations

The following procedure may be used as an alternative to Gauss–Seidel or matrix solutions of simultaneous linear equations. It is particularly applicable to steady-state nodal equations in problems in which sparse coefficient matrices are involved. 1. Open a new Excel worksheet. 2. Click on TOOLS/OPTIONS/CALCULATION TAB/check Iteration box. 3. Next, select VIEW TAB (while still under TOOLS/OPTIONS) and check Formulas under Window options. Then click OK to return to worksheet. 4. Enter equations in the worksheet using the following format: Ai = ƒ(Aj’s) For example, the equations A1 + 2A2 = 3 2A1 + 5A2 =7 would appear as shown in Figure 5.4. 5. Equations will now be in view on the worksheet. Check carefully to be sure there are no mistakes. Do not go further unless the equations are correct. If desired, the worksheet may be printed at this point to obtain a hard copy of equations. 6. Click TOOLS/OPTIONS/VIEW, and under the Windows option, remove the check on Formulas and click OK. Solutions will now appear on the worksheet, in accordance with the number of iterations selected. The default value is 100 iterations with a deviation of 0.001. These values may be changed to obtain greater accuracy. The solutions may be printed as needed.

Example 5.1: Solution of Nine Nodal Equations The following set of equations is obtained from a nodal analysis of a combined convection–conduction heat-transfer problem. Nine nodes were involved, so nine equations must be solved to obtain the temperature distribution in the solid. We have already written the equations in the format for an iterative solution. T1 = (15.625 + 1.15T2 + 1.15T4)/5.425

7326_C005.fm Page 99 Tuesday, March 7, 2006 6:19 AM

Solution of Equations A 1 2 3 4 5 6 7 8 9

T1= T2= T3= T4= T5= T6= T7= T8= T9=

99

B =(15.625+1.15*B2+1.15*B4)/5.425 =(1.15*B1+1.15*B3+31.25+2.3*B5)/10.85 =(1.15*B2+115+31.25+2.3*B6)/10.85 =(1.15*B1+2.3*B5+1.15*B7)/4.6 =(B2+B4+B6+B8)/4 =(B3+B5+B9+100)/4 =(1.15*B4+115+2.3*B8)/4.6 =(B5+B7+B9+100)/4 =(B6+B8+200)/4

1 2 3 4 5 6 7 8 9

T1= T2= T3= T4= T5= T6= T7= T8= T9=

17.86873671 19.51926393 29.93322808 51.18759724 54.59206411 67.86016025 77.69751626 79.80123229 86.91534814

FIGURE 5.5

T2 T3 T4 T5 T6 T7 T8 T9

= = = = = = = =

(1.15T1 + 1.15T3 + 31.25 + 2.3T5)/10.85 (1.15T2 +115 + 31.25 +2.3T6)/10.85 (1.15T1 + 2.3T5 + 1.15T7)/4.6 (T2 + T4 + T6 + T8)/4 (T3 + T5 + T9 + 100)/4 (1.15T4 + 115 +2.3T8)/4.6 (T5 + T7 + T9 + 100)/4 (T6 + T8 + 200)/4

The set of equations for a nine-node analysis of the problem is shown as columns A and B of the accompanying worksheet (Figure 5.5). A matrix of the nine equations would be rather sparse because each T does not connect with all of the other Ts. The equations are displayed as a group by clicking TOOLS/OPTIONS/VIEW/Formulas. The iterative solution is obtained by clicking TOOLS/OPTIONS/CALCULATION/check Iteration. The Formulas check mark is then removed, and the numerical solution is displayed as shown in Figure 5.5. The windows for the iterations and “view formulas” are shown in Figure 5.6.

5.5

Solutions of Simultaneous Linear Equations Using Matrix Inversion

We noted in solving the set of nine equations in Example 5.1 that a matrix solution to the problem would require entry of many more constants than the iterative solution, because that particular problem involved a very sparse matrix. For nonsparse matrices (or if one prefers, for sparse ones too), matrix inversion may be an attractive solution method. Excel provides a very easy procedure for obtaining such solutions. The set of linear equations may be written in the form [A][X] = [C]

(5.3)

where [A] is the coefficient matrix, [X] is the set of unknown variables, and [C] is the constant matrix. The set of two equations x1 + 2x2 = 5

7326_C005.fm Page 100 Tuesday, March 7, 2006 6:19 AM

100

What Every Engineer Should Know About Excel

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

A T1= T2= T3= T4= T5= T6= T7= T8= T9=

B =(15.625+1.15*B2+1.15*B4)/5.425 =(1.15*B1+1.15*B3+31.25+2.3*B5)/10.85 =(1.15*B2+115+31.25+2.3*B6)/10.85 =(1.15*B1+2.3*B5+1.15*B7)/4.6 =(B2+B4+B6+B8)/4 =(B3+B5+B9+100)/4 =(1.15*B4+115+2.3*B8)/4.6 =(B5+B7+B9+100)/4 =(B6+B8+200)/4

FIGURE 5.6

3x1 − 5x2 = −7 will have

[A] =

1 3

2 −5

7326_C005.fm Page 101 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

101 [C] = 5 −7

as the respective coefficient and constant matrices. The solution is expressed as [X] = [A]−1[C]

(5.4)

where [A]−1 is the inverse of the coefficient matrix, and [A]−1[C] is the product of the two indicated matrices. Excel provides two worksheet functions to perform the matrix inversion and product operations. The function MINVERSE(square array) returns the inverse of the square array designated in the parentheses. Note that a square array is required for this function. The function MMULT(matrix 1, matrix 2) returns the product of the two matrices in the parentheses. These need not be square arrays. Once the arguments are entered, pressing Ctrl+Shift+Enter activates either matrix worksheet function. If only a single value is returned instead of a matrix, you have failed to execute the Ctrl+Shift+Enter input. The procedure for obtaining matrix solutions to simultaneous linear equations is, therefore, as follows: 1. 2. 3. 4.

Enter the coefficient matrix in a worksheet as a square array. Determine the inverse of this array using the MINVERSE worksheet function. Enter the constant matrix in worksheet. Multiply the results of step 2 by the array in step 3 to obtain the solution.

Example 5.2: Nine Nodal Equations The method may be illustrated by solving the nine-equation example in Example 5.1. The worksheet is shown in Figure 5.7 in three segments. First, the 9 × 9 array for the coefficient matrix is entered as [A] in the 81 cells A4:I12, whereas the constant matrix [C] is entered in the 9 cells of U4:U12. The inverse [A]−1 is obtained by the following: 1. Activating cells K4:S12 to reserve space for [A]−1. 2. Entering the formula =MINVERSE(A4:I12) in cell K4 at the top-left corner of the array. 3. Pressing Ctrl+Shift+Enter to execute the inverse function. The coefficients of [A]−1 will appear in cells K4:S12 as shown. Next, nine cells are activated at W4:W12 to reserve space for the solution matrix [T]. The formula =MMULT(K4:S12,U4:U12) is entered in the top cell W4, and upon pressing Ctrl+Shift+Enter, the solution appears in cells W4:W12. It is understood that T1 = W4, T2 = W5, etc. The worksheet can be modified to provide this nomenclature. Finally, if one is interested, a check on the calculations may be made by executing the product [A][T] in the cells Y4:Y12. This is performed by activating these cells and entering the formula =MMULT(W4:W12,A4:I12)

7326_C005.fm Page 102 Tuesday, March 7, 2006 6:19 AM

102

What Every Engineer Should Know About Excel A 1 2 3 4 5 6 7 8 9 10 11 12

3 4 5 6 7 8 9 10 11 12 13

C

D

E

F

G

H

I

0 0 0 1.15 0 0 -4.6 1 0

0 0 0 0 1 0 2.3 -4 1

0 0 0 0 0 1 0 1 -4

J

Coefficient Matrix [A] -5.425 1.15 0 1.15 0 0 0 0 0

1.15 -10.85 1.15 0 1 0 0 0 0

0 1.15 -10.85 0 0 1 0 0 0

L

M

N

K 1 2

B

1.15 0 0 -4.6 1 0 1.15 0 0

0 2.3 0 2.3 -4 1 0 1 0

0 0 2.3 0 1 -4 0 0 1

O

P

Q

R

S

-0.0764172 -0.0994788 -0.0382086 -0.2610108 -0.4119678 -0.1305054 -0.1436907 -0.1568759 -0.0718453

-0.0263757 -0.0382086 -0.0731032 -0.0862158 -0.1305054 -0.325752 -0.0574766 -0.0718453 -0.0993993

-0.0271975 -0.0168771 -0.0070862 -0.111424 -0.0624742 -0.0249898 -0.2935502 -0.0966058 -0.0303989

-0.0388174 -0.0394262 -0.0194087 -0.1436907 -0.1568759 -0.0718453 -0.2221934 -0.3725415 -0.1110967

-0.0162983 -0.0194087 -0.023128 -0.0574766 -0.0718453 -0.0993993 -0.0699175 -0.1110967 -0.302624

[A Inverse ]= MINVERSE(A4:I12) -0.2064954 -0.0295189 -0.0055597 -0.0750357 -0.0332249 -0.0114677 -0.0271975 -0.0168771 -0.0070862

-0.0295189 -0.1060276 -0.0147595 -0.0332249 -0.0432517 -0.0166124 -0.0168771 -0.0171418 -0.0084386

T 1 2 3 4 5 6 7 8 9 10 11 12 13

-0.0055597 -0.0147595 -0.1004679 -0.0114677 -0.0166124 -0.031784 -0.0070862 -0.0084386 -0.0100556

U

Constant Matrix [C] -15.625 -31.25 -146.25 0 0 -100 -115 -100 -200

-0.0750357 -0.0332249 -0.0114677 -0.3207477 -0.113483 -0.0374851 -0.111424 -0.0624742 -0.0249898

V

W

Temperature Solution [T]= [AInverse][C] 17.86873 19.51926 29.93323 51.18759 54.59206 67.86016 77.69751 79.80123 86.91535

X

Y Calculation Check [A][T]=(?)[C]

Z

AA

-15.625 -31.25 -146.25 -1.42109E-14 1.42109E-14 -100 -115 -100 -200

FIGURE 5.7

in the cell Y4. The results in column Y should agree with those in column U. Note the agreement, except that cells Y7 and Y8 are not quite equal to zero because of roundoff errors in the calculation process. It is not necessary to display the coefficients of the inverse function [A]−1 as an intermediate step in the solution process. Instead, one may go directly to the solution as shown

7326_C005.fm Page 103 Tuesday, March 7, 2006 6:19 AM

Solution of Equations A 1 2 3 4 5 6 7 8 9 10 11 12 13 14

103

B

C

D

E

F

G

H

I

J

Coefficient Matrix [A] -5.425 1.15 0 1.15 0 0 0 0 0

1.15 -10.85 1.15 0 1 0 0 0 0

0 1.15 -10.85 0 0 1 0 0 0

1.15 0 0 -4.6 1 0 1.15 0 0

15 16

Constant Matrix [C]

17 18 19 20 21 22 23 24 25 26 27 28

-15.625 -31.25 -146.25 0 0 -100 -115 -100 -200

0 2.3 0 2.3 -4 1 0 1 0

0 0 2.3 0 1 -4 0 0 1

0 0 0 1.15 0 0 -4.6 1 0

0 0 0 0 1 0 2.3 -4 1

0 0 0 0 0 1 0 1 -4

Temperature Solution [T]=[A Inverse][C]= MMULT(MINVERSE(A4:I12),D19:D27) T1= T2= T3= T4= T5= T6= T7= T8= T9=

17.86873 19.51926 29.93323 51.18759 54.59206 67.86016 77.69751 79.80123 86.91535

FIGURE 5.8

in the second worksheet of Figure 5.8. In this case, the inverse and matrix multiplication operations are performed by activating the nine cells G19:G27 to reserve space for the solution and entering the following combination formula in cell G19: =MMULT(MINVERSE(A4:I12,D19:D22) Note that the constant matrix [C] has been moved to D19:D27 strictly as a page organization measure. Nomenclature for the T’s has been added in cells F19:F27.

5.5.1

Error Messages

If any of the cells in [A] are left open, MINVERSE will return the #VALUE! error value. It will also return this same error notice if the array does not have an equal number of rows and columns, i.e., if it is not a square array. If the determinant of [A] is zero, it is noninvertible and will return the #NUM! error value.

5.6

Solutions of Simultaneous Nonlinear Equations Using Solver

Excel Solver may be used to solve simultaneous linear or nonlinear equations. The equations are first written in the form:

7326_C005.fm Page 104 Tuesday, March 7, 2006 6:19 AM

104

What Every Engineer Should Know About Excel f1(x1, x2, …, xn) = 0 f2(x1, x2, …, xn) = 0

fn = 0

(5.5)

In the equation set (Equation 5.5) there will be n equations in n unknowns. As noted, the equations may be linear or nonlinear. A new function g(x1, x2, …, xn) is formed such that g = f12 + f22 + … + fn2

(5.6)

The solution technique is to allow Excel Solver to iterate on values of x1, x2, etc., to cause the function g to approach zero. Because of the squares in the f functions, they too will approach zero and result in a solution for the set of equations. An alternate formulation would be to express g as a sum of the absolute values of the f function through g = ∑ABS(fi(xi)). For nonlinear equations, multiple sets of solutions may result (including complex solutions), hence restrictions must be placed on the iterative process to match the physical problem represented by the equations. For example, a solution to a heattransfer problem involving absolute temperatures would require that all the temperatures be positive. These restrictions must be inserted when formulating the problem. The following is a suggested procedure for setting up the Excel worksheet to accomplish the solution: 1. In column A, type x1=, x2=, etc., for n rows. 2. In column B, adjacent to column A of step 1, insert initial estimates for values of x1, x2, etc., for n rows. These guesses should be made in accordance with the best estimate of the solution for the physical problem represented by the equations. 3. Skip a few rows, then in column A type f1=, f2=, etc., for n rows, where the fs are in the form of a set of equations (Equation 5.5). 4. In column B, adjacent to column A of step 3, type functions (=… ) according to the equation set (Equation 5.5). Use cell locations from step 2 for designating the variables. 5. Skip a few rows. 6. In column A type g=. 7. In column B and the same row as step 6, type (=… ) function according to Equation 5.6. Use cell designations for the functions from step 4. 8. Click TOOLS/SOLVER. Note that if Solver is not present, it must be installed as an add-in. The target cell is that of the function in step 7. Set this target cell equal to zero by changing cells in column B of step 2. Constraints are set according to physical problems. As noted, if absolute temperatures were the variables in a thermal problem, ≥0 might be set as the constraint. 9. A description of TOOLS/SOLVER/OPTIONS is given in Excel Help/Index under Solver, “dialog of box options”. Select options as appropriate. 10. Click Solve. A solution may or may not be obtained. If not, try repeating Solve again. Often, this will produce a solution. Or, alternate initial estimates for the variables in step 2 may be selected and the Solve procedure repeated. A solution

7326_C005.fm Page 105 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

105

A B x1= 1.00016655744427 3 4 x2= 2.00002196974879 5 x3= 3.00001005919001 6 7 8 f1= =B3+3*B4-6*B5^2+47 9 f2= =7*B3-5*B4^3+B5+30 10 f3= =2*B3^2+4*B4-6*B5+8 11 12 g= =B8^2+B9^2+B10^2 13 14 15 16 17 18 19 20 21 22 23 24 25

C

D

FIGURE 5.9

usually results. If too high a “precision” is specified, Solver may state that a solution is not found when, in fact, one has been found but not to the precision selected. The person formulating the physical problem must make a judgment call in such cases. One should not ask for unreasonable limits of precision when the uncertainties of the physical problem do not justify them.

Example 5.3: Solution of a Set of Algebraic Equations The worksheet and Solver Windows are shown in Figure 5.9 and Figure 5.10 for solutions of the following set of nonlinear equations: x1 + 3x2 – 6x32 = −47 7x1 − 5x23 + x3 = −30 2x12 + 4x2 – 6x3 = −8

7326_C005.fm Page 106 Tuesday, March 7, 2006 6:19 AM

106

What Every Engineer Should Know About Excel

FIGURE 5.10

The resulting values of the f and g functions are also given. For this problem, the constraint of B3:B5≥0 (positive values) was selected. The exact solutions are x1 = 1, x2 = 2, and x3 = 3. The first set of solutions was obtained for a selected precision of 0.01, whereas the second was for a precision of 0.0001. Note the difference in solutions and the values of the f and g functions.

Example 5.4: Radiation and Convection Heat Transfer between Two Plates A schematic of the system is shown in Figure 5.11. The temperature on the outside of the left plate is Ta, and the temperature on the outside of the right plate is Tb. The plates have different thickness and conductivities. Heat is conducted through each plate and dissipated to the fluid. A fluid moves through the space between the plates at temperature Tf, and the inner surfaces of the plates exchange heat with each other by radiation energy, which is proportional to the absolute temperature to the fourth power. In addition, the

7326_C005.fm Page 107 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

107

Tb

Ta Heat

Flow, Tf T2

T1 FIGURE 5.11

plates lose heat by convection to the fluid. The convection coefficients are proportional to temperature difference to the 0.25 power. The energy balance on each inside surface is given in Equation (a) and Equation (b) along with the temperature dependence of Eb1, Eb2, h1, and h2 in Equation (b) through Equation (f). Our objective is to determine the temperatures of the inside surfaces of the walls, T1 and T2. 1000(Ta − T1) + h1(Tf − T1) + (Eb2 − Eb1)/2.25 = 0

(a)

5000(Tb − T2) + h2(Tf − T2) + (Eb1 − Eb2)/2.25 = 0

(b)

Eb1 = 5.67E-8 × T14

(c)

Eb2 = 5.67E-8 × T24

(d)

h1 = 1.6 × (ABS(T1 − Tf))0.25

(e)

h2 = 1.6 × (ABS(T2 − Tf))0.25

(f)

The purpose of this example is to illustrate the solution of nonlinear equations, so we ask the reader to accept the format of the equations as given. Detailed information on heat-transfer formulations is available in Reference 4. The Excel worksheet is set up as shown in Figure 5.12, with the six variables located at B4:B9. The outside wall temperatures and fluid temperature are entered in column E with the values that are assigned for this particular case. Other values may be selected if the effects of different boundary conditions are to be examined. Equation (a) and Equation (b) are already in the correct format [ƒ(…) = 0], so they are entered in the worksheet at cells B11 and B12. The g function g = f12 + f22

7326_C005.fm Page 108 Tuesday, March 7, 2006 6:19 AM

108

What Every Engineer Should Know About Excel

A 1 2 3 4 5 6 7 8 9 10 11 12 13

B

C

T1= T2= h1= h2= Eb1= Eb2=

301 302 =1.6*(ABS(B4-E6))^0.25 =1.6*(ABS(B5-E6))^0.25 =0.0000000567*B4^4 =0.0000000567*B5^4

f1= f2=

=1000*(E4-B4)+B6*(E6-B4)+(B9-B8)/2.25 =500*(E5-B5)+B7*(E6-B5)+(B8-B9)/2.25

D

E

Ta= 773 Tb= 373 Tf= 300

(a)

A T1= T2= h1= h2= Eb1= Eb2=

4 5 6 7 8 9 10 11 f1= 12 f2= 13 14

B 761.6657 387.9586222 7.416549249 4.899926743 19082.73647 1284.472149

C

D Ta= Tb= Tf=

E 773 373 300

-0.006067138 0.037811483 0 001466518 (b)

FIGURE 5.12

is entered in cell B14. This is the target cell that we want to iterate to zero by changing values of T1 and T2 in cells B4 and B5. Examining Equation (a) through Equation (f), we see that the formulas in B6:B9 could have been incorporated in the formulas for f1 and f2. We choose to list them separately so that the calculated values of these quantities will become part of the solution presentation. The boundary temperatures in E4:E6 could also be inserted in the formulas, but by using this type of display they also become part of the solution presentation.

7326_C005.fm Page 109 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

FIGURE 5.12 (continued)

109

(c)

The formula displays are removed from the screen and the Solver window called by TOOLS/SOLVER. This window is shown in Figure 5.12c. From the physical nature of the problem it can be inferred that the minimum temperature in the two walls must always be greater than the fluid temperature Tf = 300 K; hence, the constraints are as shown in the Solver window. The initial guesses of 301 and 302 for T1 and T2 are shown at B4 and B5 of the formula window in Figure 5.12a. All temperatures are expressed in absolute (degrees kelvin) because of the radiation terms. After setting the target cell as B14 = 0, Solve is clicked, and the results are shown in Figure 5.12b. Note the small value of g, i.e., 0.001467 ≈ 0.

Example 5.5: Solution of Simultaneous Linear Equations Using Solver The procedure for solving a set of linear equations with Solver is the same as that for nonlinear equations. First, the equations must be written in the form ƒ(x1, …, xn) = 0. For this example, we choose the same set of equations that was solved by iteration in Example 5.1. The listing of the T variables from B1 through B9 is shown in the worksheet in Figure 5.13a. The equations for the ƒ functions are listed from B12 through B20 in this worksheet. Finally, the g function is listed as the sum of the squares of the ƒ functions in cell B22. The initial guesses for the T variables are all taken as zero in cells B1 through B9. Solver is then called by clicking TOOLS/SOLVER, and the Solver Parameters window appears as in Figure 5.13c. The target cell that contains the g function is B22, which is set to zero. The cells to be changed for the iteration process are those of the variables in B1:B9. The constraint that the solutions be greater than or equal to zero is added. Solve is then clicked and a solution is found that appears as in Figure 5.13b. All the ƒ functions and the g function have small values. The solutions for the T variables agree with the values obtained previously. Although the use of Solver to obtain a solution to simultaneous linear equations is quite satisfactory, it is more cumbersome to use than the iterative technique of Section 5.4.

7326_C005.fm Page 110 Tuesday, March 7, 2006 6:19 AM

110

What Every Engineer Should Know About Excel

FIGURE 5.13

5.7

Solver Results Dialog Box

The Solver Results dialog box for the solutions of the three nonlinear equations of Example 5.3 is shown in Figure 5.14. By checking Keep Solver Solution and then OK, the solutions will be displayed in the variable cells B3:B5, as shown. Solver provides an additional feature under the Report box. If Answer is checked, a summary answer report is generated, and will appear as a separate Answer Report sheet in the workbook. Clicking Sensitivity will produce a separate Sensitivity Report sheet in the workbook. These reports are preformatted in a style suitable for presentation or transfer to another document. The two

7326_C005.fm Page 111 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

111

Answer Report Target Cell (Value Of) Cell Name $B$12 g=

Original Value Final Value 3173 5.1842E-07

Adjustable Cells Cell $B$3 $B$4 $B$5

Original Value 0 0 0

Name x1= x2= x3=

Final Value 1.00016656 2.00002197 3.00001006

Constraints Cell $B$3 $B$4 $B$5

Name x1= x2= x3=

Cell Value Formula 1.000166557 $B$3>=0 2.00002197 $B$4>=0 3.000010059 $B$5>=0

Status Slack Not Binding 1.00016656 Not Binding 2.00002197 Not Binding 3.00001006

Sensitivity Report Adjustable Cells Cell $B$3 $B$4 $B$5

Name x1= x2= x3=

Final Reduced Value Gradient 1.00016656 0 2.00002197 0 3.00001006 0

Constraints NONE

FIGURE 5.14

reports for the current example are shown in Figure 5.14 along with the Results dialog box. Further information regarding this feature is available in Help/Index under About the Solver Results dialog box. We will find that the reports are quite useful when presenting the results of optimization problems in Chapter 8.

5.8

Comparison of Methods for Solution of Simultaneous Linear Equations

Three methods have been demonstrated for solution of simultaneous linear equations: (1) an iterative technique particularly applicable to sets of equations with sparse coefficient matrices and described in Section 5.4, (2) an iterative technique using Excel Solver described in Section 5.6, and (3) solution by matrix inversion as described in Section 5.5. In physical problems the constants in [C] often represent boundary conditions imposed on the problem, which may be varied to investigate their effects on the final solution. Their display in the separate matrix offers the advantage of somewhat more convenient adjustments than when they are embedded in the equations for an iterative solution. Elements of the constant matrix may be expressed in terms of other cell addresses that may, in turn, be varied as desired for examination of different physical boundary conditions.

7326_C005.fm Page 112 Tuesday, March 7, 2006 6:19 AM

112

What Every Engineer Should Know About Excel

For relatively large numbers of equations with sparse coefficient matrices, a large number of zeros must be entered. Over half the entries are zero in the nine-equation example (Example 5.2). An error of just one entry will result in an incorrect solution. In these cases, the iterative technique is probably the most convenient solution method. Although not as visible as in the matrix method, the boundary conditions represented as constant terms in the equations may still be referred to variable cell locations and changed as needed in the physical problem.

5.9

Copying Cell Equations for Repetitive Calculations

The drag-copy feature of Excel is very useful in applications in which repetitive calculations must be performed sequentially based on a previous result. One application is that of transient-heat-transfer analysis using finite-difference equations. The problem is usually formulated with the following nodal equation: Tip+1 = (Δτ/Ci)∑ [(Tjp – Tip)/Rij] + Tip where Tp represents temperatures at the beginning of a time increment, and Tp+ represents nodal temperatures after a time increment Δτ. A calculation of the transient temperature response of the object is performed by applying this equation sequentially to every node in the solid for as many time increments as desired. If the calculation is carried forward to a large number of time increments, the steady-state temperature distribution will be obtained. Different initial conditions may be examined very easily by changing the temperatures that start the calculation at time zero. Excel is used to advantage by writing the cell (temperature node ) formulas in reference address form and then copying them for as many time increments as needed. In this way, the p + 1 node is always specified in terms of the p node preceding it in the worksheet. The procedure for this application is then: 1. Select the number of time increments for the solution of the problem and set the number of rows required for setup equal to the number of time increments minus one. Twenty time increments will require 21 rows. 2. Enter the initial temperature conditions in the first row. 3. Enter nodal equations in the worksheet in the required format, starting with row 2. Use TOOLS/OPTIONS/VIEW/FORMULAS to display formulas in the body of the worksheet. Check carefully to see that the formulas are correct. 4. Copy (drag the mouse) cell formulas down for the number of rows selected in step 1. 5. Print out formulas, if desired, by using FILE/PAGE SETUP/SHEET/Row and Column Headings; then print using the usual procedure. 6. Return to TOOLS/OPTIONS/VIEW/WINDOW/FORMULA and remove the check. The temperature distribution will be displayed on the worksheet. Print out as needed. 7. The problem may be worked for other initial conditions by returning to step 2 and entering new values. The new solutions will appear immediately.

7326_C005.fm Page 113 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

113

A simple numerical example of this method is given below. The reader unfamiliar with heat-transfer nomenclature should not be concerned with the formulas used, but instead observe the behavior of the solution and the way the drag-copy operation is performed.

Example 5.6: Transient Temperature Distribution in a 1-D Solid A one-dimensional slab is initially at a uniform temperature. The temperature of the left surface is suddenly changed to 100°C, while that of the right surface is suddenly changed to 200°C. Determine the temperature distribution at four positions in the solid using (Δx)2/ αΔτ = 2 and a sufficient number of time increments to achieve steady state. Obtain solutions for initial temperatures of 0°C, 200°C, 300°C, and 1000°C. SOLUTION

When the transient parameter is selected as given the nodal equations become (see Reference 4 for an explanation of this parameter): Tp+1(m) = (1/2)[Tp(m + 1) + Tp(m − 1)] where m + 1 and m − 1 refer to the temperatures to the right and left of node m, respectively. Or, for row two of the worksheet, we have A2 = (100 + B1)/2; B2 = (A1 + C1)/2; C2 = (B1 + D1)/2; D2 = (C1 + 200)/2 The equations are shown in Figure 5.15, and the numerical results are given in Figure 5.16 in the accompanying printouts for 40 time increments (41 rows), which is sufficient in all cases to achieve the steady-state values of 120°, 140°, 160°, and 180°C. Note that with the use of the drag-copy, the relative address feature expresses the temperatures in each row in terms of the temperatures in the previous row. Each row represents a time increment. The specific value of the time increment would depend on the parameters Δx and α, which are not defined in the problem statement.

5.10 Creating and Running Macros A macro is a sequence of operations with keystrokes and mouse actions that may be recorded and stored for repeated use. The procedure for creating macros in Excel is most easily demonstrated with a specific example.

Example 5.7: Macro to solve f(x)-0 Create a macro to obtain the roots to f(x) = 0, where f(x) appears in cell B4 of the worksheet. Obtain the solution using Goal Seek, iterating the values of x contained in cell B3. Once the macro is created, different functions may be entered in B4 and a solution obtained with a single click action. The procedure is as follows: 1. Set up a worksheet for the way it will be used — in this case, for a Goal Seek solution of the function in cell B4, with variable x in cell B3. If any toolbars are

7326_C005.fm Page 114 Tuesday, March 7, 2006 6:19 AM

114

What Every Engineer Should Know About Excel

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

A 0 =(100+B1)/2 =(100+B2)/2 =(100+B3)/2 =(100+B4)/2 =(100+B5)/2 =(100+B6)/2 =(100+B7)/2 =(100+B8)/2 =(100+B9)/2 =(100+B10)/2 =(100+B11)/2 =(100+B12)/2 =(100+B13)/2 =(100+B14)/2 =(100+B15)/2 =(100+B16)/2 =(100+B17)/2 =(100+B18)/2 =(100+B19)/2 =(100+B20)/2 =(100+B21)/2 =(100+B22)/2 =(100+B23)/2 =(100+B24)/2 =(100+B25)/2 =(100+B26)/2 =(100+B27)/2 =(100+B28)/2 =(100+B29)/2 =(100+B30)/2 =(100+B31)/2 =(100+B32)/2 =(100+B33)/2 =(100+B34)/2 =(100+B35)/2 =(100+B36)/2 =(100+B37)/2 =(100+B38)/2 =(100+B39)/2 =(100+B40)/2

B 0 =(A1+C1)/2 =(A2+C2)/2 =(A3+C3)/2 =(A4+C4)/2 =(A5+C5)/2 =(A6+C6)/2 =(A7+C7)/2 =(A8+C8)/2 =(A9+C9)/2 =(A10+C10)/2 =(A11+C11)/2 =(A12+C12)/2 =(A13+C13)/2 =(A14+C14)/2 =(A15+C15)/2 =(A16+C16)/2 =(A17+C17)/2 =(A18+C18)/2 =(A19+C19)/2 =(A20+C20)/2 =(A21+C21)/2 =(A22+C22)/2 =(A23+C23)/2 =(A24+C24)/2 =(A25+C25)/2 =(A26+C26)/2 =(A27+C27)/2 =(A28+C28)/2 =(A29+C29)/2 =(A30+C30)/2 =(A31+C31)/2 =(A32+C32)/2 =(A33+C33)/2 =(A34+C34)/2 =(A35+C35)/2 =(A36+C36)/2 =(A37+C37)/2 =(A38+C38)/2 =(A39+C39)/2 =(A40+C40)/2

C 0 =(B1+D1)/2 =(B2+D2)/2 =(B3+D3)/2 =(B4+D4)/2 =(B5+D5)/2 =(B6+D6)/2 =(B7+D7)/2 =(B8+D8)/2 =(B9+D9)/2 =(B10+D10)/2 =(B11+D11)/2 =(B12+D12)/2 =(B13+D13)/2 =(B14+D14)/2 =(B15+D15)/2 =(B16+D16)/2 =(B17+D17)/2 =(B18+D18)/2 =(B19+D19)/2 =(B20+D20)/2 =(B21+D21)/2 =(B22+D22)/2 =(B23+D23)/2 =(B24+D24)/2 =(B25+D25)/2 =(B26+D26)/2 =(B27+D27)/2 =(B28+D28)/2 =(B29+D29)/2 =(B30+D30)/2 =(B31+D31)/2 =(B32+D32)/2 =(B33+D33)/2 =(B34+D34)/2 =(B35+D35)/2 =(B36+D36)/2 =(B37+D37)/2 =(B38+D38)/2 =(B39+D39)/2 =(B40+D40)/2

D 0 =(C1+200)/2 =(C2+200)/2 =(C3+200)/2 =(C4+200)/2 =(C5+200)/2 =(C6+200)/2 =(C7+200)/2 =(C8+200)/2 =(C9+200)/2 =(C10+200)/2 =(C11+200)/2 =(C12+200)/2 =(C13+200)/2 =(C14+200)/2 =(C15+200)/2 =(C16+200)/2 =(C17+200)/2 =(C18+200)/2 =(C19+200)/2 =(C20+200)/2 =(C21+200)/2 =(C22+200)/2 =(C23+200)/2 =(C24+200)/2 =(C25+200)/2 =(C26+200)/2 =(C27+200)/2 =(C28+200)/2 =(C29+200)/2 =(C30+200)/2 =(C31+200)/2 =(C32+200)/2 =(C33+200)/2 =(C34+200)/2 =(C35+200)/2 =(C36+200)/2 =(C37+200)/2 =(C38+200)/2 =(C39+200)/2 =(C40+200)/2

FIGURE 5.15

required, see that they are displayed at this time by clicking VIEW/TOOLBARS/ DRAWING, etc. 2. This step consists of the following actions: a. Click TOOLS/MACRO/Record New Macro. The Record Macro dialog box will appear as shown in Figure 5.17. Assign a name to the macro (Marcro1, in this case). The first character of the macro name must be a letter, followed by your choice of other letters, numbers, or symbols. Spaces are not permitted, but an underscore may be used instead of a space between words.

0 50 50 62.5 75 81.25 90.625 94.53125 100.7813 103.3203 107.4219 109.082 111.7676 112.854 114.6118 115.3229 116.4734 116.9388 117.6918 117.9964 118.4893 118.6886 119.0112 119.1417 119.3528 119.4382 119.5764 119.6323 119.7228 119.7593 119.8185 119.8425 119.8812 119.8969 119.9223 119.9325 119.9491 119.9558 119.9667 119.9711 119.9782

A 0 0 25 50 62.5 81.25 89.0625 101.5625 106.6406 114.8438 118.1641 123.5352 125.708 129.2236 130.6458 132.9468 133.8776 135.3836 135.9928 136.9785 137.3773 138.0224 138.2834 138.7057 138.8765 139.1528 139.2646 139.4455 139.5187 139.6371 139.685 139.7625 139.7938 139.8445 139.8651 139.8982 139.9117 139.9334 139.9422 139.9564 139.9622

B 0 0 50 62.5 87.5 96.875 112.5 118.75 128.9063 133.0078 139.6484 142.334 146.6797 148.4375 151.2817 152.4323 154.2938 155.0468 156.2653 156.7581 157.5556 157.8782 158.4001 158.6112 158.9529 159.091 159.3146 159.4051 159.5514 159.6106 159.7064 159.7451 159.8078 159.8332 159.8742 159.8908 159.9177 159.9285 159.9461 159.9532 159.9647

C 0 100 100 125 131.25 143.75 148.4375 156.25 159.375 164.4531 166.5039 169.8242 171.167 173.3398 174.2188 175.6409 176.2161 177.1469 177.5234 178.1326 178.3791 178.7778 178.9391 179.2001 179.3056 179.4764 179.5455 179.6573 179.7025 179.7757 179.8053 179.8532 179.8726 179.9039 179.9166 179.9371 179.9454 179.9588 179.9643 179.9731 179.9766

D

E 200 150 150 137.5 137.5 131.25 131.25 127.3438 127.3438 124.8047 124.8047 123.1445 123.1445 122.0581 122.0581 121.347 121.347 120.8817 120.8817 120.577 120.577 120.3777 120.3777 120.2472 120.2472 120.1618 120.1618 120.1059 120.1059 120.0693 120.0693 120.0454 120.0454 120.0297 120.0297 120.0194 120.0194 120.0127 120.0127 120.0083 120.0083

F 200 200 175 175 162.5 162.5 154.6875 154.6875 149.6094 149.6094 146.2891 146.2891 144.1162 144.1162 142.6941 142.6941 141.7633 141.7633 141.1541 141.1541 140.7554 140.7554 140.4944 140.4944 140.3236 140.3236 140.2118 140.2118 140.1386 140.1386 140.0907 140.0907 140.0594 140.0594 140.0389 140.0389 140.0254 140.0254 140.0166 140.0166 140.0109

G 200 200 200 187.5 187.5 178.125 178.125 171.875 171.875 167.7734 167.7734 165.0879 165.0879 163.3301 163.3301 162.1796 162.1796 161.4265 161.4265 160.9337 160.9337 160.6111 160.6111 160.4 160.4 160.2618 160.2618 160.1713 160.1713 160.1121 160.1121 160.0734 160.0734 160.048 160.048 160.0314 160.0314 160.0206 160.0206 160.0135 160.0135

H 200 200 200 200 193.75 193.75 189.0625 189.0625 185.9375 185.9375 183.8867 183.8867 182.5439 182.5439 181.665 181.665 181.0898 181.0898 180.7133 180.7133 180.4668 180.4668 180.3056 180.3056 180.2 180.2 180.1309 180.1309 180.0857 180.0857 180.0561 180.0561 180.0367 180.0367 180.024 180.024 180.0157 180.0157 180.0103 180.0103 180.0067

I

J 300 300 250 237.5 212.5 203.125 187.5 181.25 171.0938 166.9922 160.3516 157.666 153.3203 151.5625 148.7183 147.5677 145.7062 144.9532 143.7347 143.2419 142.4444 142.1218 141.5999 141.3888 141.0471 140.909 140.6854 140.5949 140.4486 140.3894 140.2936 140.2549 140.1922 140.1668 140.1258 140.1092 140.0823 140.0715 140.0539 140.0468 140.0353

L 300 300 275 250 237.5 218.75 210.9375 198.4375 193.3594 185.1563 181.8359 176.4648 174.292 170.7764 169.3542 167.0532 166.1224 164.6164 164.0072 163.0215 162.6227 161.9776 161.7166 161.2943 161.1235 160.8472 160.7354 160.5545 160.4813 160.3629 160.315 160.2375 160.2062 160.1555 160.1349 160.1018 160.0883 160.0666 160.0578 160.0436 160.0378

M 300 250 250 237.5 225 218.75 209.375 205.4688 199.2188 196.6797 192.5781 190.918 188.2324 187.146 185.3882 184.6771 183.5266 183.0612 182.3082 182.0036 181.5107 181.3114 180.9888 180.8583 180.6472 180.5618 180.4236 180.3677 180.2772 180.2407 180.1815 180.1575 180.1188 180.1031 180.0777 180.0675 180.0509 180.0442 180.0333 180.0289 180.0218

N

O

P 1000 550 550 437.5 387.5 331.25 293.75 258.5938 233.5938 210.7422 194.3359 179.3945 168.6523 158.8745 151.8433 145.4437 140.8417 136.6531 133.6411 130.8996 128.9282 127.1339 125.8436 124.6692 123.8247 123.056 122.5033 122.0002 121.6384 121.3091 121.0724 120.8568 120.7019 120.5608 120.4594 120.3671 120.3007 120.2402 120.1968 120.1572 120.1288

Q 1000 1000 775 675 562.5 487.5 417.1875 367.1875 321.4844 288.6719 258.7891 237.3047 217.749 203.6865 190.8875 181.6833 173.3063 167.2821 161.7992 157.8564 154.2678 151.6871 149.3384 147.6493 146.1121 145.0066 144.0004 143.2768 142.6183 142.1447 141.7137 141.4037 141.1216 140.9188 140.7341 140.6013 140.4805 140.3936 140.3145 140.2576 140.2058

Transient Temperatures in a Slab Row1 lists initial temperatures of 0, 200, 300, and 1000 Note that long time temperatures approach same values for all initial conditions (Row41) .

300 200 200 175 168.75 156.25 151.5625 143.75 140.625 135.5469 133.4961 130.1758 128.833 126.6602 125.7813 124.3591 123.7839 122.8531 122.4766 121.8674 121.6209 121.2222 121.0609 120.7999 120.6944 120.5236 120.4545 120.3427 120.2975 120.2243 120.1947 120.1468 120.1274 120.0961 120.0834 120.0629 120.0546 120.0412 120.0357 120.0269 120.0234

K

R 1000 1000 800 687.5 587.5 503.125 440.625 384.375 343.75 306.8359 280.2734 256.1035 238.7207 222.9004 211.5234 201.1688 193.7225 186.9453 182.0717 177.636 174.4461 171.5429 169.4551 167.5549 166.1884 164.9448 164.0504 163.2364 162.651 162.1182 161.7351 161.3864 161.1356 160.9074 160.7433 160.5939 160.4865 160.3887 160.3184 160.2544 160.2084

S 1000 600 600 500 443.75 393.75 351.5625 320.3125 292.1875 271.875 253.418 240.1367 228.0518 219.3604 211.4502 205.7617 200.5844 196.8613 193.4727 191.0358 188.818 187.2231 185.7714 184.7275 183.7775 183.0942 182.4724 182.0252 181.6182 181.3255 181.0591 180.8676 180.6932 180.5678 180.4537 180.3716 180.297 180.2432 180.1944 180.1592 180.1272

Solution of Equations

FIGURE 5.16

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

7326_C005.fm Page 115 Tuesday, March 7, 2006 6:19 AM

115

7326_C005.fm Page 116 Tuesday, March 7, 2006 6:19 AM

116

What Every Engineer Should Know About Excel

FIGURE 5.17

b. If desired, a shortcut key may be assigned for the macro at this time. The key must take the form of Ctrl + letter. Numbers are not permitted. c. Specify the storage place of the macro. “This Workbook” is chosen for this example. If the macro is to be available for all Excel workbooks, store it in the Personal Macro Workbook in the XLStart folder. d. Enter a description of the macro. 3. Click OK. The Stop Rec dialog box should appear as shown in Figure 5.17. If it does not appear, click VIEW/TOOLBARS/Stop Record. If no action is taken, the recording of the macro will be based on absolute cell references. Click the relative cell button to record on a relative cell basis. If desired, the absolute and relative reference cell basis may be alternated during the recording process. 4. Execute the procedure to obtain the roots. In this case, the solution to B4 = 0 is performed as shown in the discussion of Goal Seek solutions. Obviously, the solution to this example is very simple (B3 = 6). When the procedure execution is completed, click Stop in the Stop Rec box, or click TOOLS/MACRO/Stop Recording. a. If the recording is done on an absolute cell basis (relative cell button not clicked), the solution will be obtained for B4 = 0 by changing the values of B3. The solution appears in B3 and the residual value of f(x) appears in B4. b. If the macro is recorded on a relative cell basis (relative cell button activated), the function cell must be activated (clicked) before starting the macro. For

7326_C005.fm Page 117 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

117

A 2 3 x= 4 f(x)= 5 6 7 8 9

B

=B3-6 Macro 1 Macro1

FIGURE 5.18

example, if the function is entered in cell M9, that cell should be activated. The solution will then appear in the cell just above (or M8), therefore that cell should be reserved for display of the solution or initial guesses for the iterative Goal Seek calculation. 5. The macro is executed by pressing the shortcut key assigned (Ctrl + letter) or by clicking TOOLS/MACRO/MACROS/select Macro1, then click Run. In addition, the macro may be attached to an object or button on the worksheet that will run the macro when clicked. Two examples are shown in Figure 5.18 for this macro. a. A rectangle drawing object is created at B6 and the macro name Macro1 typed inside. The macro is assigned by activating the rectangle, right clicking, and then followed by Assign Macro with Macro1 selected in the dialog box. b. A special button is created at B8 by clicking VIEW/TOOLBARS/FORMS/ Button (second row, second column). The Assign Macro box will appear. Make the assignment and then click OK. The button will remain activated; if not, activate by pressing Ctrl while clicking on the periphery of the button. Type the title of the macro in the button using a desired style and font. c. For both the rectangle and button, click FORMAT/CONTROL/PROPERTIES/ select choice for object (button) positioning. If object (button) is to be shown on the printout of the worksheet, click Print Object. Click X in the Forms dialog box to remove it from the screen.

Example 5.8: Solution of the Transcendental Equation from Section 5.2 Create the aforementioned macro and apply it to the solution for the roots of the transcendental equation in Section 5.2. Note that the transcendental equation x tanx – 2 has multiple roots. Use several initial guesses (both positive and negative) in cell B3 to produce values of these roots. Initial guesses of 1.0, 2.0, and 10.0 produce results of 1.07684, 3.64361, and 9.62964, respectively. Initial guesses of −1.0, −2.0, and −10.0 will display the corresponding negative values for the roots.

7326_C005.fm Page 118 Tuesday, March 7, 2006 6:19 AM

118

What Every Engineer Should Know About Excel

Problems 5.1

Solve the following equations using both Goal Seek and Solver: a. b. c. d. e. f. g. h.

5.2

x = 0.09[1 − (1+x)−n] for n = 5, 10, 15, and 20 4x3 − 3x2 + 2x − 87 = 0 xsinx − 1 = 0 xe−0.1x = 1 x3 − (0.647)2[(1 − x)2(2 + x)] = 0 3.587(1 + 0.04x2/3) = 0.0668x 8.3(302 − x) = 5.102 × 10−8(x4 − 278) 4.74(300 − x)1/4 + 5.102 × 10−8(5004 − x4) = 0

Solve the following sets of linear equations using both the iterative technique and matrix inversion: a. 10x2 + 10x5 + 12.5 = 21.25x1 5x1 + 5x3 + 10x6 + 12.5 = 21.25 x2 5x2 + 5x4 + 10x7 + 12.5 = 21.25x3 10x3 + 12.5 = 11.25x4 10x1 + 50x6 + 12000 = 100x5 25x5 + 25x7 + 10x2 + 12000 = 100x6 50x6 + 20x3 = 70x7 b. 1100 + x3 + x4 = 4x1 600 + x3 + x4 = 4x2 900 + x1 + x2 = 4x3 800 + x1 + x2 = 4x4 c. 75 + 2x5 +x2/4 + 16 = 3.3x1 x1/4 + x3/4 + 2x6 + 16 = 3.3x2 x2/4 +x4/4 + 2x7 + 16 = 3.3x3 x3/4 + x8 + 8 + 4 = 1.85x4 4x1 + x6/2 + 150 = 5x5 4x2 + x7/2 + x5/2 = 5x6 4x3 + x6/2 + x8/2 = 5x7 2x4 + x7/2 + 5 = 2.9x8 d. x2/2 + 50 + 16x3 =17.75x1 x1/2 + 16x4 +50 = 17.75x2 x4 + 100 + 16x5 + 16x1 = 34x3 x3 + 100 + 16x6 + 16x2 = 34x4

7326_C005.fm Page 119 Tuesday, March 7, 2006 6:19 AM

Solution of Equations

119

x6/2 + 50 + 16x3 = 17x5 x5/2 + 50 + 16x4 = 17x6 e. (57000 − x1)/4 + (460 − x1)/90 + (x2 − x1)/19 = 0 (x1 − x2)/19 + (460 − x2)/31 + (x3 − x2)/64 = 0 (460 − x3)/8 +(x2 − x3)/64 = 0 5.4

Solve the following sets of nonlinear equations using Solver: a. 1300(T2 − T1) + 1.42[ABS(300 − T1)]1/4 + 5.7 × 10−8(3004 − T14) = 0 T3 + T1 − 2T2 = 0 500 + T2 − 2T3 = 0 with the restriction that 300 < T < 500 b. 1300[1 + 0.00025(T2 + T1)](T2 − T1) + 1.42[ABS(300 − T1)]1/4 + 5.7×10-8(3004 − T14 =0 [1 + 0.00025(T3 + T2)](T3 − T2) + [1 + 0.00025(T1 + T2)](T1 − T2) = 0 [1 + 0.00025(1000+T3)](1000 − T3) + [1 + 0.00025(T2 + T3)](T2 − T3) = 0 with the restriction that 300 < T < 1000 c. x12 + sinx − 2x2 = 1.4674 x1x2 + x23 = 2.5708 with the restriction that x1, x2 > 0 d. x12 + x22 = 5 x1 + 3x2 = 7 x2 + x32 − x1 =5 for all x > 0 e. 3.38 − p + [(101.3 − p))(310 − T)]/(1538 − T) = 0 ln(p/2337) = 6789(1/293.15 − 1/T) p and T are positive values

5.5

The following set of equations describes the performance of a crossflow finnedtube heat exchanger: e = 1 − exp{[exp(−NCn) − 1]/Cn} n = N−0.22 DTh = 0.67e

C = 2100/Cmin

DTh = 40300/Cmin

N = 2100/Cmin

Determine the values of the six variables. All values must be positive. 5.6

The temperature ratio in a pin fin is described by the equation Tr = [cosh m(L − x) + (h/mk)sinh m(L − x)]/[cosh mL + (h/mk)sinh mL]

7326_C005.fm Page 120 Tuesday, March 7, 2006 6:19 AM

120

What Every Engineer Should Know About Excel where m = (hP/kA)1/2; P = πd; A = πd2/4 In a fin with d = 0.01 m, and L = 0.1 m, the temperature ratios are measured at two x locations giving Tr = 0.56 at x = 0.04 m Tr = 0.365 at x = 0.08 m Using Solver, determine the values of h and k.

5.7

The amplitude response for a seismic instrument is described by the equation: a = x2/[(1-x2)2 + (2Cx)2]1/2 where x = ω/ωn, C = c/cc, cc = (4mk)1/2, and ωn = (k/m)1/2 Three amplitude measurements are taken giving: a = 0.98 at ω = 75 Hz a = 2 at ω = 100 Hz a = 1.5 at ω = 166 Hz Using these data and Solver, determine values of m and k.

7326_C006.fm Page 121 Tuesday, March 7, 2006 6:19 AM

6 Other Operations

6.1

Introduction

In this chapter, we gather some operations that do not fall easily into the topics covered in other chapters. These items are: 1. 2. 3. 4. 5. 6.

Numerical integration Use of logical IF function Histograms Normal error (probability) distributions Calculation of uncertainty propagation in experiments Multivariable linear and exponential regression analysis with LINEST and LOGEST worksheet functions 7. Examples and comparison of regression methods Examples are given for each topic and some coordination between the use of histograms, cumulative frequency distributions, and the normal error distributions is presented.

6.2

Numerical Evaluation of Integrals

Numerical evaluation of integrals may be performed in Excel by using either the trapezoidal rule or Simpson’s rule. First, the area under the curve y = ƒ(x) is divided into increments of Δx. In the trapezoidal rule the curve is replaced by a series of straight line segments, and the area of each element under the curve is calculated as a product of the mean height and the width Δx. Thus, Ai = Δx(yi + yi+1)/2 Taking the variables as ranging from 1 to n in indices, the total area under the curve will be I = ∫ydx = A = (1/2)(y1 + 2y2 + … + 2yn−1 + yn)Δx = [(y1 + yn)/2 + ∑yi]Δx

(6.1)

121

7326_C006.fm Page 122 Tuesday, March 7, 2006 6:19 AM

122

What Every Engineer Should Know About Excel

where the sum is carried out from i = 2 to i = n − 1. If the increments in x are not uniform the elemental areas are Ai = ymΔxi = (yi + yi+1)(xi+1 − xi)/2

(6.2)

The total area under the curve is then obtained by summing all the elemental areas. Simpson’s rule fits a series of parabolas to consecutive sets of three points on the curve such that the area may be calculated from I = ∫ydx = (y1 + 4y2 + 2y3 + 4y4 + 2y5 + … +2yn-2 +4yn−1 + yn)Δx/3

(6.3)

for uniform increments in x. If the area under the curve is divided into an even number of equally spaced values of Δx, the integral becomes I = {yi + yn + ∑yi[3 + (−1)i+1]} × Δx/3

(6.4)

where the summation is performed from i = 2 to i = n – 1. For an even number of increments in Δx, the number of data points will be odd. The larger the number of increments in x, the better will be the approximation of the integral.

Example 6.1: Integration of Sine function The worksheets shown in Figure 6.1 are set up to calculate the integral of sin(x) over the interval of 0 < x < π. The exact value of the integral is equal to -cos(x) evaluated from 0 to π radians, which gives −(−1 − 1), or an exact value of 2.0. The worksheet is arranged to allow for different values of the increment Δx, which is assigned in cell I4. We will present the results for two Δx increments: π/10 and π/22. In both cases we have an even number of increments, so Equation 6.4 is used for evaluation with Simpson’s rule. In Figure 6.1a, values of x are listed for the 26-increment case in column A, starting with zero and stepping up by increments specified in cell I4. Column B calculates the corresponding values of sin(x). The first area (or integral) calculation is made using the trapezoidal rule of Equation 6.1. Half the values of y1 and yn are entered in cells C4 and C26, respectively, whereas the other y-values are copied in cells C5:C25 from cells B5:B25. Cell C29 then calculates the sum of the cells C4:C26 multiplied by the Δx increment to yield an area of 1.9966002 (−0.016999% error) as shown in Figure 6.1c. For the calculation using Simpson’s rule, the “i” index is created in column E and the arguments of the summation of Equation 6.4 are computed in cells F4:F26. Cell C29 then sums the entries of column F and multiplies by Δx/3 in accordance with Equation 6.4. The result for the calculated area is 2.00000462 (0.000231% error). The same calculation is made for 10 increments in x, and the results are displayed in Figure 6.1b. Use of fewer increments gives an area of 1.9835235 (−0.823825% error) for the trapezoidal rule and 2.0001095179 (0.005476% error) when Simpson’s rule is applied. In both cases, Simpson’s rule is more accurate than the trapezoidal rule.

Example 6.2: Numerical Integration of Experimental Data We now examine a hypothetical set of experimental data shown as the variables x and y at the top left of the worksheet of Figure 6.2. The data are expected to follow a linear variation and hence are plotted on a linear x-y scatter graph as shown in Figure 6.2a

7326_C006.fm Page 123 Tuesday, March 7, 2006 6:19 AM

Other Operations A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

123

Rule

x

B Trapezoidal y = SIN(x)

C

D

E

F

0 =A4+$I$4 =A5+$I$4 =A6+$I$4 =A7+$I$4 =A8+$I$4 =A9+$I$4 =A10+$I$4 =A11+$I$4 =A12+$I$4 =A13+$I$4 =A14+$I$4 =A15+$I$4 =A16+$I$4 =A17+$I$4 =A18+$I$4 =A19+$I$4 =A20+$I$4 =A21+$I$4 =A22+$I$4 =A23+$I$4 =A24+$I$4 =A25+$I$4

=SIN(A4) =SIN(A5) =SIN(A6) =SIN(A7) =SIN(A8) =SIN(A9) =SIN(A10) =SIN(A11) =SIN(A12) =SIN(A13) =SIN(A14) =SIN(A15) =SIN(A16) =SIN(A17) =SIN(A18) =SIN(A19) =SIN(A20) =SIN(A21) =SIN(A22) =SIN(A23) =SIN(A24) =SIN(A25) =SIN(A26)

=B4/2 =B5 =B6 =B7 =B8 =B9 =B10 =B11 =B12 =B13 =B14 =B15 =B16 =B17 =B18 =B19 =B20 =B21 =B22 =B23 =B24 =B25 =B26/2

1 =E4+1 =E5+1 =E6+1 =E7+1 =E8+1 =E9+1 =E10+1 =E11+1 =E12+1 =E13+1 =E14+1 =E15+1 =E16+1 =E17+1 =E18+1 =E19+1 =E20+1 =E21+1 =E22+1 =E23+1 =E24+1 =E25+1

=B4 =B5*(3+(-1)^E5 =B6*(3+(-1)^E6) =B7*(3+(-1)^E7) =B8*(3+(-1)^E8) =B9*(3+(-1)^E9) =B10*(3+(-1)^E10) =B11*(3+(-1)^E11) =B12*(3+(-1)^E12) =B13*(3+(-1)^E13) =B14*(3+(-1)^E14) =B15*(3+(-1)^E15) =B16*(3+(-1)^E16) =B17*(3+(-1)^E17) =B18*(3+(-1)^E18) =B19*(3+(-1)^E19) =B20*(3+(-1)^E20) =B21*(3+(-1)^E21) =B22*(3+(-1)^E22) =B23*(3+(-1)^E23) =B24*(3+(-1)^E24) =B25*(3+(-1)^E25) =B26

AREA=

=(SUM(C4:C26))*I4

AREA=

=(SUM(F4:F26))*I4/3

G Rule

Simpson's

H

I

Index Dx=

=PI()/22 Pi/22)

(a) A B 1 Trapezoidal 2 x y = SIN(x) 3 4 0 0 5 0.314159 0.309016994 6 0.628319 0.587785252 7 0.942478 0.809016994 8 1.256637 0.951056516 9 1.570796 1 10 1.884956 0.951056516 11 2.199115 0.809016994 12 2.513274 0.587785252 13 2.827433 0.309016994 14 3.141593 1.22515E-16 15 16 AREA=

C

D

E

F Simpson's

Rule

G Rule

H

I

Index 0 0.309017 0.5877853 0.809017 0.9510565 1 0.9510565 0.809017 0.5877853 0.309017 6.126E-17 1.9835235

1 2 3 4 5 6 7 8 9 10 11 AREA=

0 1.236067977 1.175570505 3.236067977 1.902113033 4 1.902113033 3.236067977 1.175570505 1.236067977 1.22515E-16

Dx=

0.314159265 (Pi/10)

2.000109517

(b) FIGURE 6.1

through Figure 6.2d. The graph in Figure 6.2a is a type 4 scatter graph with straight line segments joining the data points, the graph in Figure 6.2b is a type 3 scatter graph with a computer-smoothed curve joining the points, and the graph in Figure 6.2c is a type 1 scatter graph. The graph in Figure 6.2d is the same as that in Figure 6.2c but with the addition of a linear trendline fit for the data.

7326_C006.fm Page 124 Tuesday, March 7, 2006 6:19 AM

124

What Every Engineer Should Know About Excel A 1 2 x 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

B Trapezoidal y = SIN(x)

0 0.142799666 0.285599332 0.428398998 0.571198664 0.71399833 0.856797996 0.999597663 1.142397329 1.285196995 1.427996661 1.570796327 1.713595993 1.856395659 1.999195325 2.141994991 2.284794657 2.427594323 2.570393989 2.713193655 2.855993321 2.998792988 3.141592654

0 0.142314838 0.281732557 0.415415013 0.540640817 0.654860734 0.755749574 0.841253533 0.909631995 0.959492974 0.989821442 1 0.989821442 0.959492974 0.909631995 0.841253533 0.755749574 0.654860734 0.540640817 0.415415013 0.281732557 0.142314838 1.01069E-15

AREA=

C

D

E

F Simpson's

Rule

G H Rule

I

Index 0 0.142314838 0.281732557 0.415415013 0.540640817 0.654860734 0.755749574 0.841253533 0.909631995 0.959492974 0.989821442 1 0.989821442 0.959492974 0.909631995 0.841253533 0.755749574 0.654860734 0.540640817 0.415415013 0.281732557 0.142314838 5.05347E-16

1.99660022

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

AREA=

0 0.569259353 0.563465114 1.661660052 1.081281635 2.619442936 1.511499149 3.365014131 1.819263991 3.837971894 1.979642884 4 1.979642884 3.837971894 1.819263991 3.365014131 1.511499149 2.619442936 1.081281635 1.661660052 0.563465114 0.569259353 1.01069E-15

Dx=

0.142799666 (Pi/22)

2.000004631

(c) FIGURE 6.1 (continued)

If a linear plot is expected from either physical reasoning or previous experience, then Figure 6.2d may be the preferred vehicle for presentation of the data. It is interesting to perform a numerical integration of the data over the range 0 < x < 5 with increments Δx = 0.5, the same as used for the data increments. The integration is performed similar to that of the sine function in Figure 6.1 using both the trapezoidal rule and Simpson’s rule. In Figure 6.3a the formulas are displayed, whereas in Figure 6.3b the computed values of the integral in cell C19 for the trapezoidal integration and in cell F19 for Simpson’s rule are shown. The computed values are 24.15 and 23.8666667, respectively. It is interesting to compare these numbers with those obtained by integrating over the trendline of Figure 6.2d. The trendline is represented by y = 1.9145x + 0.0318 and the area under the curve by Area = ∫ydx = [1.9145x2/2 + 0.0318x] 05 = 24.09025 This value compares favorably with the results obtained in the numerical integration shown earlier, and may be the best representation of the data because it is determined by the trendline fit. The smoothed curve in Figure 6.2b is probably unrealistic, and the scatter of the data is best taken into account by the least-squares trendline fit in Figure 6.2d.

7326_C006.fm Page 125 Tuesday, March 7, 2006 6:19 AM

Other Operations x 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

125

y 0.2 0.7 2.1 2.2 4.6 4.8 5.4 7 8.2 8.6 9.2

10

10

9

9

8

8

7

7

6

6

5

5

4

4

3

3

2

2

1

1

0

0 0

1

2

3

4

0

5

1

2

3

4

5

12

10 9 8 7

y= 1.9145x+ 0.0318 2 R = 0.9823

10 8

6 5 4 3 2 1 0

6 4 2 0 0

1

2

3

4

5

0

1

2

3

4

5

FIGURE 6.2

6.3

Use of Logical IF Statement

The IF statement enables a branching of calculations based on a true or false result of a logical test. The function takes the form: IF (logical test, go to ____ if test is true, or go to_____if test is false)

Example 6.3: Nested IF Statements and Embedded Documentation Figure 6.4 shows the worksheet for a calculation that uses two nested IF functions (seven are permitted) to choose the proper calculation equation for flat-plate heat-transfer coefficients. The three equations are listed in mathematical format in the block at the bottom of the sheet, along with restrictions on their range of applicability in terms of the ReL parameter. This block was composed in Word and then copied to the Excel worksheet. The equations are written in Excel format in cells C14, C15, and C16. The value of the Re parameter (Reynolds number) that determines which equation is to be used is calculated

7326_C006.fm Page 126 Tuesday, March 7, 2006 6:19 AM

126

What Every Engineer Should Know About Excel A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

B

C

D

E

T rap ezoidal Ru le x 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

F S imp son's Ru le

y

In dex

0.2 0.7 2.1 2.2 4.6 4.8 5.4 7 8.2 8.6 9.2

= B6/2 = B7 = B8 = B9 = B10 = B11 = B12 = B13 = B14 = B15 =B16/2

1 = E6+1 = E7+1 = E8+1 = E9+1 =E10+1 =E11+1 =E12+1 =E13+1 =E14+1 =E15+1

= B6 =B7*(3+(-1)^E 7) =B8*(3+(-1)^E 8) =B9*(3+(-1)^E 9) = B10*(3+ (-1)^E 10) = B11*(3+ (-1)^E 11) = B12*(3+ (-1)^E 12) = B13*(3+ (-1)^E 13) = B14*(3+ (-1)^E 14) = B15*(3+ (-1)^E 15) = B16

AREA=

=(S UM(C 6:C16))*0.5

AREA =

=(S UM(F6:F16))*0.5/3

(a)

A

B

C D Trap ezoidal Rule

1 2 3 4

x

y

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

0.2 0.7 2.1 2.2 4.6 4.8 5.4 7 8.2 8.6 9.2

E

F S imp son 's Ru le

In dex

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

AREA=

0.1

1

0.2

0.7

2

2.8

2.1

3

4.2

2.2

4

8.8

4.6

5

9.2

4.8

6

19.2

5.4

7

10.8

7

8

28

8.2

9

16.4

8.6

10

34.4

4.6

11

9.2

24.15

(b) FIGURE 6.3

AREA =

23.8666667

7326_C006.fm Page 127 Tuesday, March 7, 2006 6:19 AM

Other Operations

127

B 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

C

D

FLAT PLATE HEAT TRANSFER

rho= mu= u= L= k= Pr= Re= A= Re= havg= havg= havg= havg,calc=

Valu

0.03 0.7 =C1 0. =C5*C7*C8/C6 =(C9/C8)*0.664*(C11^0.5)*C10^0.3333 =(C9/C8)*(C10^0.3333)*(0.037*(C11^0.8)-871) =(C9/C8)*(C10^0.3333)*(0.228*C11*((LOG(C11))^-2.584)-871) =IF(C11
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF