Introduction To Matlab For Engineers - CUHK CSE

3y ago
66 Views
13 Downloads
5.41 MB
577 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Esmeralda Toy
Transcription

pal34870 ifc.qxd1/7/107:44 PMPage iNumbered Examples:Chapters One to EightNumber and TopicNumber and TopicChapter One4.7–11.1–11.6–1Volume of a circular cylinderPiston motionChapter �22.4–32.4–42.5–12.6–12.7–1Vectors and displacementAortic pressure modelTransportation route analysisCurrent and power dissipation inresistorsA batch distillation processMiles traveledHeight versus velocityManufacturing cost analysisProduct cost analysisEarthquake-resistant building designAn environmental databaseA student databaseChapter Three3.2–1Optimization of an irrigation channel4.9–14.9–2Chapter Five5.2–1Height and speed of a projectileSeries calculation with a for loopPlotting with a for loopData sortingFlight of an instrumented rocketSeries calculation with a while loopGrowth of a bank accountTime to reach a speci ed heightPlotting orbitsChapter rature dynamicsHydraulic resistanceEstimation of traf c owModeling bacteria growthBreaking strength and alloycompositionResponse of a biomedical instrumentChapter Seven7.1–17.2–17.2–27.3–1Chapter ��24.6–3Using the switch structure for calendarcalculationsA college enrollment model: Part IA college enrollment model: Part IIBreaking strength of threadMean and standard deviation of heightsEstimation of height distributionStatistical analysis and manufacturingtolerancesChapter Eight8.1–18.2–18.2–28.2–38.2–4The matrix inverse methodLeft division method with threeunknownsCalculations of cable tensionAn electric resistance networkEthanol production

pal34870 fm i-xii 1.qxd1/7/107:44 PMPage iNumbered Examples:Chapters Eight to ElevenNumber and –2An underdetermined set with threeequations and three unknownsA statically indeterminate problemThree equations in three unknowns,continuedProduction planningTraf c engineeringThe least-squares methodAn overdetermined setChapter ��1Velocity from an accelerometerEvaluation of Fresnel’s cosine integralDouble integral over a nonrectangularregionResponse of an RC circuitLiquid height in a spherical tankA nonlinear pendulum modelTrapezoidal pro le for a dc motorNumber and TopicChapter 210.5–110.6–1#Simulink solution of y 10 sin tExporting to the MATLAB workspace#Simulink model for y - 10y f (t)Simulink model of a two-masssuspension systemSimulink model of a rocket-propelledsledModel of a relay-controlled motorResponse with a dead zoneModel of a nonlinear pendulumChapter Eleven11.3–111.3–211.5–1Intersection of two circlesPositioning a robot armTopping the Green Monster

pal34870 fm i-xii 1.qxd1/7/107:44 PMPage iiiIntroduction to MATLAB for EngineersWilliam J. Palm IIIUniversity of Rhode IslandTM

pal34870 fm i-xii 1.qxd1/15/1011:41 AMPage ivTMINTRODUCTION TO MATLAB FOR ENGINEERS, THIRD EDITIONPublished by McGraw-Hill, a business unit of The McGraw-Hill Companies, Inc., 1221 Avenue of the Americas,New York, NY 10020. Copyright 2011 by The McGraw-Hill Companies, Inc. All rights reserved. Previouseditions 2005 and 2001. No part of this publication may be reproduced or distributed in any form or by anymeans, or stored in a database or retrieval system, without the prior written consent of The McGraw-HillCompanies, Inc., including, but not limited to, in any network or other electronic storage or transmission, orbroadcast for distance learning.Some ancillaries, including electronic and print components, may not be available to customers outside theUnited States.This book is printed on acid-free paper containing 10% postconsumer waste.1 2 3 4 5 6 7 8 9 0 DOC/DOC 1 0 9 8 7 6 5 4 3 2 1 0ISBN 978-0-07-353487-9MHID 0-07-353487-0Vice President & Editor-in-Chief: Martin LangeVice President, EDP: Kimberly Meriwether DavidGlobal Publisher: Raghu SrinivasanSponsoring Editor: Bill StenquistMarketing Manager: Curt ReynoldsDevelopment Editor: Lora NeyensSenior Project Manager: Joyce WattersDesign Coordinator: Margarite ReynoldsCover Designer: Rick D. NoelPhoto Research: John LelandCover Image: Ingram Publishing/AGE FotostockProduction Supervisor: Nicole BaumgartnerMedia Project Manager: Joyce WattersCompositor: MPS Limited, A Macmillan CompanyTypeface: 10/12 Times RomanPrinter: RRDonnellyAll credits appearing on page or at the end of the book are considered to be an extension of the copyright page.Library of Congress Cataloging-in-Publication DataPalm, William J. (William John), 1944–Introduction to MATLAB for engineers / William J. Palm III.—3rd ed.p. cm.Includes bibliographical references and index.ISBN 978-0-07-353487-91. MATLAB. 2. Numerical analysis—Data processing. I. Title.QA297.P33 2011518.0285—dc222009051876www.mhhe.com

pal34870 fm i-xii 1.qxd1/7/107:44 PMPage vTo my sisters, Linda and Chris, and to my parents, Lillian and William

pal34870 fm i-xii 1.qxd1/7/107:44 PMPage viABOUT THE AUTHORis Professor of Mechanical Engineering at the University ofRhode Island. In 1966 he received a B.S. from Loyola College in Baltimore, andin 1971 a Ph.D. in Mechanical Engineering and Astronautical Sciences fromNorthwestern University in Evanston, Illinois.During his 38 years as a faculty member, he has taught 19 courses. One ofthese is a freshman MATLAB course, which he helped develop. He has authoredeight textbooks dealing with modeling and simulation, system dynamics, controlsystems, and MATLAB. These include System Dynamics, 2nd Edition (McGrawHill, 2010). He wrote a chapter on control systems in the Mechanical Engineers’Handbook (M. Kutz, ed., Wiley, 1999), and was a special contributor to the ftheditions of Statics and Dynamics, both by J. L. Meriam and L. G. Kraige (Wiley,2002).Professor Palm’s research and industrial experience are in control systems,robotics, vibrations, and system modeling. He was the Director of the RoboticsResearch Center at the University of Rhode Island from 1985 to 1993, and is thecoholder of a patent for a robot hand. He served as Acting Department Chairfrom 2002 to 2003. His industrial experience is in automated manufacturing;modeling and simulation of naval systems, including underwater vehicles andtracking systems; and design of control systems for underwater-vehicle enginetest facilities.William J. Palm IIIvi

pal34870 fm i-xii 1.qxd1/9/103:59 PMPage viiCONTENTSPreface ixCHAPTERCHAPTER11.1 MATLAB Interactive Sessions 41.2 Menus and the Toolbar 161.3 Arrays, Files, and Plots 181.4 Script Files and the Editor/Debugger 271.5 The MATLAB Help System 331.6 Problem-Solving Methodologies 381.7 Summary 46Problems 472Numeric, Cell, and Structure ArraysProgram Design and Development 148Relational Operators and LogicalVariables 1554.3 Logical Operators and Functions 1574.4 Conditional Statements 1644.5 for Loops 1714.6 while Loops 1834.7 The switch Structure 1884.8 Debugging MATLAB Programs 1904.9 Applications to Simulation 1934.10 Summary 199Problems 2004.14.2An Overview of MATLAB 3CHAPTER53One- and Two-Dimensional NumericArrays 542.2 Multidimensional Numeric Arrays 632.3 Element-by-Element Operations 642.4 Matrix Operations 732.5 Polynomial Operations Using Arrays 852.6 Cell Arrays 902.7 Structure Arrays 922.8 Summary 96Problems 972.1CHAPTER4Programming with MATLAB 147CHAPTERxy Plotting Functions 219Additional Commands andPlot Types 2265.3 Interactive Plotting in MATLAB5.4 Three-Dimensional Plots 2465.5 Summary 251Problems 2515.15.23Functions and Files 1133.1 Elementary Mathematical Functions 1133.2 User-De ned Functions 1193.3 Additional Function Topics 1303.4 Working with Data Files 1383.5 Summary 140Problems 1405Advanced Plotting 219CHAPTER2416Model Building and Regression2636.1 Function Discovery 2636.2 Regression 2716.3 The Basic Fitting Interface 2826.4 Summary 285Problems 286vii

pal34870 fm i-xii 1.qxdviii1/7/107:44 PMPage viiiContentsCHAPTER7Statistics, Probability, andInterpolation 2957.1 Statistics and Histograms 2967.2 The Normal Distribution 3017.3 Random Number Generation 3077.4 Interpolation 3137.5 Summary 322Problems 324CHAPTER8Linear Algebraic Equations3318.1 Matrix Methods for Linear Equations 3328.2 The Left Division Method 3358.3 Underdetermined Systems 3418.4 Overdetermined Systems 3508.5 A General Solution Program 3548.6 Summary 356Problems 357CHAPTER9Numerical Methods for Calculus andDifferential Equations 3699.1 Numerical Integration 3709.2 Numerical Differentiation 3779.3 First-Order Differential Equations 3829.4 Higher-Order Differential Equations 3899.5 Special Methods for Linear Equations 3959.6 Summary 408Problems ms 443Dead Time in Models 448Simulation of a Nonlinear VehicleSuspension Model 45110.10 Summary 455Problems 45610.710.810.910419Simulation Diagrams 420Introduction to Simulink 421Linear State-Variable Models 427Piecewise-Linear Models 430Transfer-Function Models 437Nonlinear State-Variable Models 441CHAPTERMuPAD11465Introduction to MuPAD 466Symbolic Expressions and Algebra 472Algebraic and TranscendentalEquations 47911.4 Linear Algebra 48911.5 Calculus 49311.6 Ordinary Differential Equations 50111.7 Laplace Transforms 50611.8 Special Functions 51211.9 Summary 514Problems 51511.111.211.3APPENDIXAGuide to Commands and Functions inThis Text 527APPENDIXBAnimation and Sound in MATLABAPPENDIXCFormatted Output in MATLAB 549APPENDIXReferencesAPPENDIXD553ESome Project Suggestionswww.mhhe.com/palmAnswers to Selected Problems 554Index 557538

pal34870 fm i-xii 1.qxd1/7/107:44 PMPage ixP R E FA C EFormerly used mainly by specialists in signal processing and numericalanalysis, MATLAB in recent years has achieved widespread and enthusiastic acceptance throughout the engineering community. Many engineering schools now require a course based entirely or in part on MATLAB early inthe curriculum. MATLAB is programmable and has the same logical, relational,conditional, and loop structures as other programming languages, such as Fortran,C, BASIC, and Pascal. Thus it can be used to teach programming principles. Inmost schools a MATLAB course has replaced the traditional Fortran course, andMATLAB is the principal computational tool used throughout the curriculum. Insome technical specialties, such as signal processing and control systems, it isthe standard software package for analysis and design.The popularity of MATLAB is partly due to its long history, and thus it iswell developed and well tested. People trust its answers. Its popularity is also dueto its user interface, which provides an easy-to-use interactive environment thatincludes extensive numerical computation and visualization capabilities. Itscompactness is a big advantage. For example, you can solve a set of many linearalgebraic equations with just three lines of code, a feat that is impossible with traditional programming languages. MATLAB is also extensible; currently morethan 20 “toolboxes” in various application areas can be used with MATLAB toadd new commands and capabilities.MATLAB is available for MS Windows and Macintosh personal computersand for other operating systems. It is compatible across all these platforms, whichenables users to share their programs, insights, and ideas. This text is based onMATLAB version 7.9 (R2009b). Some of the material in Chapter 9 is basedon the control system toolbox, Version 8.4. Chapter 10 is based on Version 7.4 ofSimulink . Chapter 11 is based on Version 5.3 of the Symbolic Math toolbox.TEXT OBJECTIVES AND PREREQUISITESThis text is intended as a stand-alone introduction to MATLAB. It can be used inan introductory course, as a self-study text, or as a supplementary text. The text’smaterial is based on the author’s experience in teaching a required two-creditsemester course devoted to MATLAB for engineering freshmen. In addition,the text can serve as a reference for later use. The text’s many tables and itsreferencing system in an appendix have been designed with this purpose in mind.A secondary objective is to introduce and reinforce the use of problemsolving methodology as practiced by the engineering profession in general and MATLAB and Simulink are a registered trademarks of The MathWorks, Inc.ix

pal34870 fm i-xii 1.qxdx1/7/107:44 PMPage xPrefaceas applied to the use of computers to solve problems in particular. This methodology is introduced in Chapter 1.The reader is assumed to have some knowledge of algebra and trigonometry;knowledge of calculus is not required for the rst seven chapters. Some knowledge of high school chemistry and physics, primarily simple electric circuits, andbasic statics and dynamics is required to understand some of the examples.TEXT ORGANIZATIONThis text is an update to the author’s previous text.* In addition to providing newmaterial based on MATLAB 7, especially the addition of the MuPAD program,the text incorporates the many suggestions made by reviewers and other users.The text consists of 11 chapters. The rst chapter gives an overview ofMATLAB features, including its windows and menu structures. It also introducesthe problem-solving methodology. Chapter 2 introduces the concept of an array,which is the fundamental data element in MATLAB, and describes how to use numeric arrays, cell arrays, and structure arrays for basic mathematical operations.Chapter 3 discusses the use of functions and les. MA TLAB has an extensive number of built-in math functions, and users can de ne their own functionsand save them as a le for reuse.Chapter 4 treats programming with MATLAB and covers relational and logical operators, conditional statements, for and while loops, and the switchstructure. A major application of the chapter’s material is in simulation, to whicha section is devoted.Chapter 5 treats two- and three-dimensional plotting. It rst establishes standards for professional-looking, useful plots. In the author’s experience, beginningstudents are not aware of these standards, so they are emphasized. The chapterthen covers MATLAB commands for producing different types of plots and forcontrolling their appearance.Chapter 6 covers function discovery, which uses data plots to discover amathematical description of the data. It is a common application of plotting, anda separate section is devoted to this topic. The chapter also treats polynomial andmultiple linear regression as part of its modeling coverage.Chapter 7 reviews basic statistics and probability and shows how to useMATLAB to generate histograms, perform calculations with the normal distribution, and create random number simulations. The chapter concludes with linearand cubic spline interpolation. The following chapters are not dependent on thematerial in this chapter.Chapter 8 covers the solution of linear algebraic equations, which arise in applications in all elds of engineering. This coverage establishes the terminologyand some important concepts required to use the computer methods properly. Thechapter then shows how to use MATLAB to solve systems of linear equationsthat have a unique solution. Underdetermined and overdetermined systems arealso covered. The remaining chapters are independent of this chapter.*Introduction to MATLAB 7 for Engineers, McGraw-Hill, New York, 2005.

pal34870 fm i-xii 1.qxd1/7/107:44 PMPage xiPrefaceChapter 9 covers numerical methods for calculus and differential equations.Numerical integration and differentiation methods are treated. Ordinary differential equation solvers in the core MATLAB program are covered, as well as thelinear system solvers in the Control System toolbox. This chapter provides somebackground for Chapter 10.Chapter 10 introduces Simulink, which is a graphical interface for buildingsimulations of dynamic systems. Simulink has increased in popularity andhas seen increased use in industry. This chapter need not be covered to readChapter 11.Chapter 11 covers symbolic methods for manipulating algebraic expressionsand for solving algebraic and transcendental equations, calculus, differentialequations, and matrix algebra problems. The calculus applications include integration and differentiation, optimization, Taylor series, series evaluation, andlimits. Laplace transform methods for solving differential equations are also introduced. This chapter requires the use of the Symbolic Math toolbox, which includes MuPAD. MuPAD is a new feature in MATLAB. It provides a notebookinterface for entering commands and displaying results, including plots.Appendix A contains a guide to the commands and functions introducedin the text. Appendix B is an introduction to producing animation and soundwith MATLAB. While not essential to learning MATLAB, these features arehelpful for generating student interest. Appendix C summarizes functions forcreating formatted output. Appendix D is a list of references. Appendix E,which is available on the text’s website, contains some suggestions forcourse projects and is based on the author’s experience in teaching a freshmanMATLAB course. Answers to selected problems and an index appear at theend of the text.All gures, tables, equations, and exercises have been numbered accordingto their chapter and section. For example, Figure 3.4–2 is the second gure inChapter 3, Section 4. This system is designed to help the reader locate theseitems. The end-of-chapter problems are the exception to this numbering system.They are numbered 1, 2, 3, and so on to avoid confusion with the in-chapterexercises.The rst four chapters constitute a course in the essentials of MA TLAB. Theremaining seven chapters are independent of one another, and may be covered inany order or may be omitted if necessary. These chapters provide additional coverage and examples of plotting and model building, linear algebraic equations,probability and statistics, calculus and differential equations, Simulink, and symbolic processing, respectively.SPECIAL REFERENCE FEATURESThe text has the following special features, which have been designed to enhanceits usefulness as a reference. Throughout each of the chapters, numerous tables summarize the commands and functions as they are introduced.xi

pal34870 fm i-xii 1.qxdxii1/7/107:44 PMPage xiiPreface Appendix A is a complete summary of all the commands and functionsdescribed in the text, grouped by category, along with the number of thepage on which they are introduced.At the end of each chapter is a list of the key terms introduced in thechapter, with the page number referenced.Key terms have been placed in the margin or in section headings wherethey are introduced.The index has four sections: a listing of symbols, an alphabetical list ofMATLAB commands and functions, a list of Simulink blocks, and analphabetical list of topics.PEDAGOGICAL AIDSThe following pedagogical aids have been included: Each chapter begins with an overview.Test Your Understanding exercises appear throughout the chapters nearthe relevant text. These relatively straightforward exercises allow readersto assess their grasp of the material as soon as it is covered. In most casesthe answer to the exercise is given with the exercise. Students should workthese exercises as they are encountered.Each chapter ends with numerous problems, grouped according to therelevant section.Each chapter contains numerous practical examples. The major examplesare numbered.Each chapter has a summary section that reviews the chapter’s objectives.Answers to many end-of-chapter problems appear at the end of the text.These problems are denoted by an asterisk next to their number (forexample, 15*).Two features have been included to motivate the student toward MATLABand the engineering profession: Most of the examples and the problems deal with engineering applications.These are drawn from a variety of engineering elds and show realisticapplications of MATLAB. A guide to these examples appears on the insidefront cover.The facing page of each chapter contains a photograph of a recentengineering achievem

MATLAB is the principal computational tool used throughout the curriculum. In some technical specialties, such as signal processing and control systems, it is the standard software package for analysis and design. The popularity of MATLAB is partly due to its long history, and thus it is well developed and well tested. People trust its answers. Its popularity is also due to its user interface .

Related Documents:

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

MATLAB tutorial . School of Engineering . Brown University . To prepare for HW1, do sections 1-11.6 – you can do the rest later as needed . 1. What is MATLAB 2. Starting MATLAB 3. Basic MATLAB windows 4. Using the MATLAB command window 5. MATLAB help 6. MATLAB ‘Live Scripts’ (for algebra, plotting, calculus, and solving differential .

19 MATLAB Excel Add-in Hadoop MATLAB Compiler Standalone Application MATLAB deployment targets MATLAB Compiler enables sharing MATLAB programs without integration programming MATLAB Compiler SDK provides implementation and platform flexibility for software developers MATLAB Production Server provides the most efficient development path for secure and scalable web and enterprise applications

MATLAB tutorial . School of Engineering . Brown University . To prepare for HW1, do sections 1-11.6 – you can do the rest later as needed . 1. What is MATLAB 2. Starting MATLAB 3. Basic MATLAB windows 4. Using the MATLAB command window 5. MATLAB help 6. MATLAB ‘Live Scripts’ (for

3. MATLAB script files 4. MATLAB arrays 5. MATLAB two‐dimensional and three‐dimensional plots 6. MATLAB used‐defined functions I 7. MATLAB relational operators, conditional statements, and selection structures I 8. MATLAB relational operators, conditional statements, and selection structures II 9. MATLAB loops 10. Summary

I. Introduction to Programming Using MATLAB Chapter 1: Introduction to MATLAB 1.1 Getting into MATLAB 1.2 The MATLAB Desktop Environment 1.3 Variables and Assignment Statements 1.4 Expressions 1.5 Characters and Encoding 1.6 Vectors and Matrices Chapter 2: Introduction to MATLAB Programming 2.1 Algorithms 2.2 MATLAB Scripts 2.3 Input and Output

foundation of basic MATLAB applications in engineering problem solving, the book provides opportunities to explore advanced topics in application of MATLAB as a tool. An introduction to MATLAB basics is presented in Chapter 1. Chapter 1 also presents MATLAB commands. MATLAB is considered as the software of choice. MATLAB can be used .

Compiler MATLAB Production Server Standalone Application MATLAB Compiler SDK Apps Files Custom Toolbox Python With MATLAB Users With People Who Do Not Have MATLAB.lib/.dll .exe . Pricing Risk Analytics Portfolio Optimization MATLAB Production Server MATLAB CompilerSDK Web Application