Tải bản đầy đủ (.pdf) (846 trang)

An engineers guide to MATLAB with applications from mechanical, aerospace, electrical, civil, and biological systems engineering, 3rd edition

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (9.45 MB, 846 trang )


An Engineer’s Guide
to MATLAB®


This page intentionally left blank


An Engineer’s Guide
to MATLAB®
With Applications from Mechanical,
Aerospace, Electrical, Civil, and
Biological Systems Engineering
Third Edition
Edward B. Magrab
Department of Mechanical Engineering, University of Maryland, College Park, MD

Shapour Azarm
Department of Mechanical Engineering, University of Maryland, College Park, MD

Balakumar Balachandran
Department of Mechanical Engineering, University of Maryland, College Park, MD

James H. Duncan
Department of Mechanical Engineering, University of Maryland, College Park, MD

Keith E. Herold
Fischell Department of Bioengineering, University of Maryland, College Park, MD

Gregory C. Walsh
Leica Geosystems, Inc., San Ramon, CA



Prentice Hall
Boston Columbus Indianapolis New York San Francisco Upper Saddle River
Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo


VP/Editorial Director, Engineering/Computer Science: Marcia J. Horton
Assistant/Supervisor: Dolores Mars
Senior Editor: Tacy Quinn
Associate Editor: Dee Bernhard
Director of Marketing: Margaret Waples
Senior Marketing Manager: Tim Galligan
Marketing Assistant: Mack Patterson
Senior Managing Editor: Scott Disanno
Project Manager: Greg Dulles
Senior Operations Supervisor: Alan Fischer
Production Manager: Wanda Rockwell
Creative Director: Jayne Conte
Cover Designer: Bruce Kenselaar
Cover Art: Getty Images, Inc.
Media Editor: Daniel Sandin
Composition: Integra
Printer/Binder: Courier Companies, Inc.

Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook
appear on appropriate pages within text.

MATLAB and Simulink are registered trademarks of The Mathworks, Inc., 3 Apple Hill, Natick MA 01760-2098.


Copyright © 2011, 2005, 2000 Pearson Education, Inc., publishing as Prentice Hall, One Lake Street, Upper Saddle
River, New Jersey 07458. All rights reserved. Manufactured in the United States of America. This publication is
protected by Copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying,
recording, or likewise. To obtain permission(s) to use material from this work, please submit a written request to
Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458.

Many of the designations by manufacturers and seller to distinguish their products are claimed as trademarks.
Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations
have been printed in initial caps or all caps.

Library of Congress Cataloging in Publication Data

ISBN 13: 978-0-13-199110-1
ISBN 10:
0-13-199110-8


For June Coleman Magrab


This page intentionally left blank


Contents
List of Examples
Preface to Third Edition
1

Introduction
Edward B. Magrab

1.1

1.2

1.3
1.4
1.5

2

2.7

xxi
1

Introduction 1
1.1.1 Organization of the Book and Its Goals 2
1.1.2 Some Suggestions on How to Use MATLAB 2
1.1.3 Book Notation Conventions 3
The MATLAB Environment 3
1.2.1 Introduction 3
1.2.2 Preliminaries—Command Window Management 5
1.2.3 Executing Expressions from the MATLAB Command
Window—Basic MATLAB Syntax 8
1.2.4 Clarification and Exceptions to MATLAB’S Syntax 11
1.2.5 MATLAB Functions 14
1.2.6 Creating Scripts and Executing Them from the
MATLAB Editor 19
Online Help 29
The Symbolic Toolbox 32

Summary of Functions Introduced in Chapter 1 41
Exercises 42

Vectors and Matrices
Edward B. Magrab
2.1
2.2
2.3
2.4
2.5
2.6

xv

51

Introduction 51
Definitions of Matrices and Vectors 52
Creation of Vectors 53
Creation of Matrices 64
Dot Operations 83
Mathematical Operations with Matrices 92
2.6.1 Addition and Subtraction 92
2.6.2 Multiplication 92
2.6.3 Determinants 101
2.6.4 Matrix Inverse 104
2.6.5 Solution of a System of Equations 107
Summary of Functions Introduced in Chapter 2 112
Exercises 113
vii



viii

3

Contents

Data Input/Output
Edward B. Magrab
3.1

3.2

3.3
3.4
3.5
3.6

4

Strings and Annotated Output 127
3.1.1 Creating Strings 127
3.1.2 Converting Numerical Values to Strings and
Displaying Them 130
Entering Data with input 135
3.2.1 Entering a Scalar with input 135
3.2.2 Entering a String with input 136
3.2.3 Entering a Vector with input 137
3.2.4 Entering a Matrix with input 137

Input/Output Data Files 137
Cell Arrays 141
Input Microsoft Excel Files 143
Summary of Functions Introduced in Chapter 3 144
Exercises 145

Program Flow Control
Edward B. Magrab
4.1
4.2

4.3

5

127

Introduction—The Logical Operator 148
Control of Program Flow 151
4.2.1 Branching—If Statement 151
4.2.2 Branching—Switch Statement 154
4.2.3 For Loop 155
4.2.4 While Loop 162
4.2.5 Early Termination of Either a for or a while Loop
Summary of Functions Introduced in Chapter 4 166
Exercises 167

148

166


Function Creation and Selected MATLAB Functions
Edward B. Magrab
5.1

5.2

Introduction 173
5.1.1 Why Use Functions 173
5.1.2 Naming Functions 174
5.1.3 Length of Functions 174
5.1.4 Debugging Functions 174
User-Defined Functions 175
5.2.1 Introduction 175
5.2.2 Function File 175
5.2.3 Subfunctions 181
5.2.4 Anonymous Functions 183
5.2.5 inline 184
5.2.6 Comparison of the Usage of Subfunctions, Anonymous
Functions, and inline 185

172


Contents

5.3
5.4

5.5


5.6
5.7

6

ix

User-Defined Functions, Function Handles, and feval 186
MATLAB Functions that Operate on Arrays of Data 187
5.4.1 Introduction 187
5.4.2 Fitting Data with Polynomials—polyfit/polyval 188
5.4.3 Fitting Data with spline 190
5.4.4 Interpolation of Data—interp1 192
5.4.5 Numerical Integration—trapz 193
5.4.6 Area of a Polygon—polyarea 195
5.4.7 Digital Signal Processing—fft and ifft 196
MATLAB Functions that Require User-Defined Functions 201
5.5.1 Zeros of Functions—fzero and roots/poly 202
5.5.2 Numerical Integration—quadl and dblquad 207
5.5.3 Numerical Solutions of Ordinary Differential
Equations—ode45 212
5.5.4 Numerical Solutions of Ordinary Differential
Equations—bvp4c 217
5.5.5 Numerical Solutions of Delay Differential
Equations—dde23 231
5.5.6 Numerical Solutions of One-Dimensional Parabolic–Elliptic
Partial Differential Equations—pdepe 233
5.5.7 Local Minimum of a Function—fminbnd 235
5.5.8 Numerical Solutions of Nonlinear Equations—fsolve 238

Symbolic Solutions and Converting Symbolic Expressions into
Functions 240
Summary of Functions Introduced in Chapter 5 246
Exercises 247

2D Graphics
Edward B. Magrab
6.1
6.2

6.3

Introduction: Graphics Management 266
Basic 2D Plotting Commands 269
6.2.1 Introduction 269
6.2.2 Changing a Graph’s Overall Appearance 281
6.2.3 Special Purpose Graphs 281
6.2.4 Reading, Displaying, and Manipulating Digital Images
Graph Annotation and Enhancement 291
6.3.1 Introduction 291
6.3.2 Axes and Curve Labels, Figure Titles, Legends,
and Text Placement 291
6.3.3 Filling Regions 294
6.3.4 Greek Letters, Mathematical Symbols, Subscripts,
and Superscripts 296
6.3.5 Altering the Attributes of Axes, Curves, Text,
and Legends 299
6.3.6 Positioning One Figure Inside Another Figure 304

265


288


x

Contents

6.4
6.5

7

Lines in 3D 338
Surfaces 341
Summary of Functions Introduced in Chapter 7
Exercises 370

338

369

Engineering Statistics
Edward B. Magrab
8.1
8.2

8.3
8.4
8.5


8.6

8.7

9

318

3D Graphics
Edward B. Magrab
7.1
7.2
7.3

8

6.3.7 Interactive Plotting Tools 306
6.3.8 Animation 307
Examples 309
Summary of Functions Introduced in Chapter 6
Exercises 319

Descriptive Statistical Quantities 377
Probability Distributions 383
8.2.1 Discrete Distributions 383
8.2.2 Continuous Distributions 387
Confidence Intervals 397
Hypothesis Testing 401
Linear Regression 404

8.5.1 Simple Linear Regression 404
8.5.2 Multiple Linear Regression 408
Design of Experiments 415
8.6.1 Single-Factor Experiments:
Analysis of Variance 415
8.6.2 Multiple-Factor Factorial Experiments 419
Summary of Functions Introduced in Chapter 8 435
Exercises 436

Dynamics and Vibrations
Balakumar Balachandran
9.1

9.2

377

Dynamics of Particles and Rigid Bodies 446
9.1.1 Planar Pendulum 446
9.1.2 Orbital Motions 447
9.1.3 Principal Moments of Inertia 450
9.1.4 Stability of a Rigid Body 451
Single-Degree-of-Freedom Vibratory Systems 454
9.2.1 Introduction 454
9.2.2 Linear Systems: Free Oscillations 456
9.2.3 Linear Systems: Forced Oscillations 462
9.2.4 Nonlinear Systems: Free Oscillations 469
9.2.5 Nonlinear Systems: Forced Oscillations 478

445



Contents

9.3

9.4

9.5

10

Systems with Multiple Degrees of Freedom 481
9.3.1 Two-Degree-of-Freedom Systems: Free
and Forced Oscillations 481
9.3.2 Natural Frequencies and Mode Shapes 495
Free and Forced Vibrations of Euler–Bernoulli
and Timoshenko Beams 499
9.4.1 Natural Frequencies and Mode Shapes of Euler–Bernoulli
and Timoshenko Beams 499
9.4.2 Forced Oscillations of Euler–Bernoulli
Beams 509
Summary of Functions Introduced in
Chapter 9 513
Exercises 514

Control Systems
Gregory C. Walsh
10.1


10.2

10.3

10.4

10.5

10.6

11

xi

524

Introduction to Control System Design 525
10.1.1 Tools for Controller Design 527
10.1.2 Naming and File Conventions 528
Representation of Systems in MATLAB 528
10.2.1 State–Space Models 530
10.2.2 Transfer-Function Representation 535
10.2.3 Discrete-Time Models 538
10.2.4 Block Diagrams and SIMULINK 542
10.2.5 Conversion Between Representations 546
Response of Systems 547
10.3.1 Estimating Response from Systems 548
10.3.2 Estimating Response from Poles and Zeros 551
10.3.3 Estimating Systems from Response 558
Design Tools 560

10.4.1 Design Criteria 561
10.4.2 Design Tools 564
Design Examples 573
10.5.1 Notch Control of a Flexible Pointer 574
10.5.2 PID Control of a Magnetic Suspension System 582
10.5.3 Lead Control of an Inverted Pendulum 589
10.5.4 Control of a Magnetically Suspended Flywheel 596
Summary of Functions Introduced in Chapter 10 605
Exercises 606

Fluid Mechanics
James H. Duncan
11.1

Hydrostatics 614
11.1.1 Pressure Distribution in the Standard Atmosphere
11.1.2 Force on a Planar Gate 616

614

615


xii

Contents

11.2

11.3


11.4
11.5

12

Heat Transfer
Keith E. Herold
12.1

12.2

12.3

13

Internal Viscous Flow 621
11.2.1 Laminar Flow in a Horizontal Pipe with Circular
Cross Section 621
11.2.2 Downward Turbulent Flow in a Vertical Pipe 622
11.2.3 Three Connected Reservoirs 624
External Flow 626
11.3.1 Boundary Layer on an Infinite Plate Started
Suddenly from Rest 626
11.3.2 Blasius Boundary Layer 628
11.3.3 Potential Flow 631
11.3.4 Joukowski Airfoils 636
Open Channel Flow 641
Biological Flows 646
Exercises 648


659

Conduction Heat Transfer 660
12.1.1 Transient Heat Conduction in a Semi-Infinite Slab
with Surface Convection 660
12.1.2 Transient Heat Conduction in an Infinite Solid Cylinder
with Convection 662
12.1.3 Transient One-Dimensional Conduction with a Heat
Source 664
Convection Heat Transfer 668
12.2.1 Internal Flow Convection: Pipe Flow 668
12.2.2 Thermal Boundary Layer on a Flat Plate: Similarity
Solution 672
12.2.3 Natural Convection Similarity Solution 677
Radiation Heat Transfer 682
12.3.1 Radiation View Factor: Differential Area to Arbitrary
Rectangle in Parallel Planes 682
12.3.2 View Factor Between Two Rectangles in
Parallel Planes 685
12.3.3 Enclosure Radiation with Diffuse Gray Walls 687
12.3.4 Transient Radiation Heating of a Plate in a Furnace 690
Exercises 692

Optimization
Shapour Azarm
13.1

13.2
13.3


Definition, Formulation, and Graphical Solution
13.1.1 Introduction 703
13.1.2 Graphical Solution 703
Linear Programming 706
Binary Integer Programming 709

702
703


Contents

13.4

13.5

13.6
13.7
13.8

14

xiii

Nonlinear Programming: Unconstrained and Curve Fitting 710
13.4.1 Unconstrained Optimization 710
13.4.2 Curve Fitting: One Independent Variable 713
13.4.3 Curve Fitting: Several Independent Variables 715
Nonlinear Programming: Constrained Single Objective 719

13.5.1 Constrained Single-Variable Method 719
13.5.2 Constrained Multivariable Method 721
13.5.3 Quadratic Programming 730
13.5.4 Semi-Infinitely Constrained Method 732
Multiobjective Optimization 736
Genetic Algorithm-Based Optimization 742
Summary of Functions Introduced in Chapter 13 751
Exercises 752

Biological Systems: Transport of Heat, Mass, and
Electric Charge
Keith E. Herold
14.1

14.2

14.3

Index

769

Heat Transfer in Biological Systems 770
14.1.1 Heat Transfer in Perfused Tissue 770
14.1.2 Thermal Conductivity Determination 773
Mass Transfer in Biological Systems 775
14.2.1 Bicarbonate Buffer System 775
14.2.2 Carbon Dioxide Transport in Blood 778
14.2.3 Oxygen Transport in Blood 779
14.2.4 Perfusion Bioreactor 782

14.2.5 Supply of Oxygen to a Spherical Tumor 786
14.2.6 Krogh Cylinder Model of Tissue Oxygenation 789
Charge Transport in Biological Systems 796
14.3.1 Hodgkin–Huxley Neuron Model 796
14.3.2 Hodgkin–Huxley Gating Parameters 797
14.3.3 Hodgkin–Huxley Model with Step Function Input 802
14.3.4 Action Potential 804
Exercises 807

813


This page intentionally left blank


List of Examples
Chapter 1
1.1
1.2
1.3
1.4

Usage of MATLAB functions 18
Flow in a circular channel 27
Determination of curvature 37
Maximum response amplitude of a single-degree-of-freedom
system 39

Chapter 2
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
2.14
2.15
2.16
2.17
2.18
2.19
2.20
2.21
2.22
2.23
2.24

Analysis of the elements of a vector 64
Creation of a special matrix 74
Rearrangement of submatrices of a matrix 75
Vector exponentiation 84
Creation of matrix elements 86
Polar to Cartesian coordinates 87

Summing a series 88
Approximation to the normal cumulative
distribution function 89
Convergence of a series 90
Evaluation of the hyperbolic secant 91
Polar to Cartesian coordinates revisited 95
Mode shape of a circular membrane 96
A solution to the Laplace equation 97
Summation of a Fourier series 100
Eigenvalues of an oscillating spring-mass system 102
Transformation of a polynomial 103
Equation of a straight line determined from two
distinct points 104
Inverse of a matrix 105
Symbolic inverse of a matrix 106
Solution of a system of equations 108
Temperatures in a slab 109
Current flowing in an electrical resistor circuit 110
Static deflection of a clamped square plate 110
Symbolically obtained Euler transformation matrix 111

Chapter 4
4.1
4.2
4.3
4.4

Fatigue strength factors 153
Selecting one of four views of a surface 155
Creation of a sequentially numbered matrix 156

Dot multiplication of matrices 157

xv


xvi

List of Examples

4.5
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
4.14
4.15

Analysis of the amplitude response of a two degree-of-freedom
system 157
Example 2.2 revisited 158
Total interest of a loan 159
Equivalent implementation of find 160
Equivalent implementation of cumsum 161
Specification of the elements of an array 161
Sorting a vector of numerical values in ascending order 162
Ensuring that data are input correctly 162

Convergence of a series 163
Approximation to p 164
Multiple root finding using interval halving 164

Chapter 5
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13
5.14
5.15
5.16
5.17
5.18
5.19
5.20
5.21
5.22
5.23
5.24
5.25

5.26

Neuber’s constant for the notch sensitivity of steel 189
Fitting data to an exponentially decaying sine wave 190
First zero crossing of an exponentially decaying sine wave 192
Area of an exponentially decaying sine wave 193
Length of a line in space 194
Fourier transform of a sine wave 198
Cross correlation of two pulses 200
Lowest five natural frequency coefficients of a clamped beam 206
Zero of a function expressed as a series 207
Determination of area and centroid 208
Area of an exponentially decaying sine wave revisited 209
Response of a single degree-of-freedom system to a ramp
force—numerical solution 209
Probability of two correlated variables 211
Natural convection along a heated vertical plate 214
Pendulum absorber 215
Displacement of a uniformly loaded Euler beam 222
Displacement of a uniformly loaded Euler beam with an
overhang 223
Displacement of an Euler beam subjected to a point load 226
Displacement of an Euler beam with a step change in cross
section 227
Lowest natural frequency coefficient of an Euler beam clamped
at both ends 229
Machine tool chatter in turning 232
Response of a single degree-of-freedom system to a
ramp force 237
Inverse kinematics 239

Intersection of a parabola and an ellipse 239
Inverse Laplace transform 241
Evaluation of a convolution integral and its characteristics 242


List of Examples

5.27
5.28
5.29

Symbolic solution of algebraic equations 243
Symbolic solution of a differential equation 244
Symbolic solution used by several different functions

xvii

245

Chapter 6
6.1
6.2
6.3
6.4
6.5
6.6
6.7
6.8

Response of a single degree-of-freedom system to

periodic forcing 305
Animation of a slider–crank mechanism 308
Polar plot: far field radiation pattern of a sound source 309
Displaying and labeling multiple curves: notch sensitivity
for steel 311
Stability of a loaded structure 312
Nontraditional histogram 313
Frequency response functions of a two degree-of-freedom
system 315
Sudoku: Drawing squares 317

Chapter 7
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8

Drawing wire-frame boxes 339
Sine wave drawn on the surface of a cylinder 341
Drawing wire-frame boxes: coloring the box surfaces 357
Intersection of a cylinder and a sphere and the highlighting of
their intersection 358
Natural frequencies of a beam hinged at both ends and restrained
by a spring at an interior point 359
Enhancing 2D graphs with 3D objects 361
Generation of planes and their projections 363

Rotation and translation of 3D objects: Euler angles 366

Chapter 8
8.1
8.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9
8.10
8.11
8.12

Determination of several statistical quantities 379
Probability of getting airplanes airborne 385
Adequacy of hospital resources 387
Verification of the normality of data 391
Normal distribution approximation to the Poisson and binomial
distributions 393
Verification that data can be represented by a Weibull
distribution 395
Two-sided confidence limits 399
Test for statistical significance of the mean
and the variance 402
Regression analysis 406
Multiple regression analysis 411
Single-factor analysis of variance 417

Two-factor analysis of variance 421


xviii

List of Examples

8.13
8.14
8.15

Three-factor analysis of variance: stiffness of
fiberglass–epoxy beams 423
Analysis of a 24 factorial experiment 429
Analysis of a 24 factorial experiment
with one replicate 432

Chapter 9
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
9.10
9.11
9.12

9.13
9.14
9.15
9.16
9.17
9.18
9.19
9.20
9.21

Orbital motions for different initial conditions 448
Principal moments of inertia 450
Stability of a rigid body 452
Oscillations of a single degree-of-freedom system for given initial
velocity and initial displacement 457
Estimate of damping factor from the logarithmic decrement 459
Machine Tool Chatter 460
Estimation of natural frequency and damping factor for a damped
oscillator 464
Curve fitting of the amplitude–response function 464
Single-degree-of-freedom system subjected to periodic pulse train
forcing 466
System with nonlinear spring 469
System with Coulomb damping 472
System with piecewise linear springs 475
Two-degree-of-freedom system subjected to
an initial velocity 485
Impulse and step responses of a two-degree-offreedom system 486
Amplitude–response function of a two-degree-of-freedom
system 489

Optimal parameters for a vibration absorber 491
Half sine wave base excitation of a two-degree-of-freedom
system 493
Natural frequencies and mode shapes of a three-degree-of-freedom
system 496
Natural frequencies and mode shapes of a four-degree-of-freedom
system 497
Natural frequencies and modes shapes of Euler–Bernoulli
and Timoshenko beams with attachments 504
Impulse response of an Euler–Bernoulli beam 511

Chapter 10
10.1
10.2
10.3
10.4
10.5

State–space model of a servomotor 531
Step response of a servomotor 534
Conversion of a continuous-time model to a discrete-time model
Tracking error of a motor control system 549
Response of a DC motor to initial conditions 550

540


List of Examples

10.6

10.7
10.8
10.9
10.10

xix

Step response of first-order system to a range of pole locations
Step response of second-order system to a range of pole
locations 552
Effects of zeros near poles of a second order system 556
Masking of modal dynamics 557
Controller design to meet rise time and percentage overshoot
criteria 565

551

Chapter 11
11.1
11.2
11.3
11.4
11.5
11.6
11.7
11.8
11.9
11.10
11.11
11.12

11.13

Temperature and pressure variation as a function of altitude
Properties of a reservoir 618
Laminar flow in a pipe that is started from rest 621
Flow rate in a pipe 623
Flow rates from three connected reservoirs 625
Acceleration of a liquid layer 627
Laminar boundary layer on a flat plate 630
Streamline pattern using contour 633
Direct calculation of streamlines 634
Flow over a Joukowski airfoil 638
Uniform channel with an overfall 642
Reservoir discharge 644
Laminar pulsatile flow in a pipe 646

Chapter 12
12.1
12.2
12.3
12.4
12.5
12.6
12.7
12.8
12.9
12.10

Transient heat conduction time and temperature distributions
in a semi-infinite solid 661

Transient heat conduction in an infinite solid cylinder with
convection 663
One-dimensional transient heat transfer with source 666
Heat transfer coefficient for laminar flow in a pipe 670
Heat transfer from a flat plate: Blasius formulation 674
Natural convection along a heated plate 679
View factor for a differential area and a finite rectangle in
parallel planes 683
View factor between two parallel rectangles 686
Total heat transfer rate of a rectangular enclosure 689
Transient radiation heating of a plate in a furnace 691

Chapter 13
13.1
13.2
13.3
13.4
13.5
13.6

Equilibrium position of a two-spring system 703
Production planning 707
Oil refinery profits 708
Loading of a knapsack 709
Equilibrium position of a two-spring system revisited
Bottom of a bottle 712

711

615



xx

List of Examples

13.7
13.8
13.9
13.10
13.11
13.12
13.13
13.14
13.15
13.16
13.17
13.18
13.19
13.20
13.21
13.22
13.23

Stress–strain relationship 714
Stress–strain relationship revisited 716
Semiempirical P–v–T relationship 716
Mineral exploration 717
Piping cost in a plant 720
Maximum volume of a closed box 720

Two-bar truss 722
Helical compression spring 723
Gear reducer 727
Production planning revisited 731
Planar two-link manipulator 733
Vibrating platform 738
Production planning revisited 741
Loading of a knapsack revisited: single objective with binary
variables 744
Two-bar truss revisited: single objective with continuous
variables 745
Two-bar truss revisited: multiobjectives with continuous
variables 747
Two-bar truss revisited: single objective with continuous and
discrete variables 748

Chapter 14
14.1
14.2
14.3
14.4
14.5
14.6
14.7
14.8
14.9
14.10

Ablation of a spherical tumor 770
Determination of the thermal conductivity of a biological

material 774
Carbonic acid titration curve 777
Blood calculations 780
Perfusion bioreactor 784
Oxygen diffusion in a small tumor 787
Krogh cylinder model with a parabolic blood velocity profile
Display of Hodgkin–Huxley gating parameters 799
Step input to Hodgkin–Huxley model 802
Hodgkin–Huxley action potential 805

792


Preface to Third Edition
In going from the previous edition to this third edition, we have made many significant
changes. A new chapter, “Biological Systems: Transport of Heat, Mass, and Electric
Charge,” has been added. To make room for this new material, Chapter 8, “Machine
Design,” of the previous edition has been removed. In Chapter 1,“Introduction,” more
details on the setup of user preferences and the use of the MATLAB editor are provided,
and the number of exercises has been significantly increased. Also, the Symbolic
toolbox has been moved to this chapter. In Chapter 5, “Function Creation and Selected MATLAB Functions,” the section dealing with the differential equation solvers now
includes the delay differential equations solver (dde23) and the one-dimensional
parabolic–elliptic partial differential equations solver (pdepe). In addition, the range
of examples for the ordinary differential equations solver bvp4c has been expanded to
better illustrate its wide applicability. Chapter 6, “2D Graphics,” contains twice the
number of special-purpose graph functions, more material on the enhancement of
graphs, and several new examples replacing those used in the second edition. Chapter
9, “Vibrations,” has been extensively revised and expanded to include a wider range of
applications. Chapter 13 “Optimization,” has also been expanded to demonstrate the
use of the new Genetic Algorithm and Direct Search toolbox.

Overall, the book has been “refreshed” to reflect the authors’ collective
experiences with MATLAB, to introduce the new enhancements that are available
in the MATLAB editor, and to include some of the new functions that have been
introduced since the last edition. Overall, the examples, exercises, and MATLAB
functions presented in the book have been increased by more than 25%. The book
now contains 190 numbered examples, almost 300 exercises, and more than 375
MATLAB functions that are illustrated. The programs in this edition have been run
on Version 2009a.

NEW TO THE EDITION
• Text was revised and tested throughout for the latest version of the software:
release 2009a
• A new chapter has been added: Biological Systems: Transport of Heat, Mass,
and Electric Charge
• 25% increase in number of examples, exercises, and Matlab functions
• Range of applications increased to include biology and electrical engineering
• Chapter 5 Function Creation and Selected Matlab Functions now includes the
delay differential equations solver (dde23) and the one-dimensional parabolicelliptic partial differential equations solver (pdepe).
xxi


xxii

Preface to Third Edition

• Expanded coverage in Chapter 9 Vibrations gives a wider range of applications.
• Chapter 13 Optimization has been expanded to demonstrate the use of the
new Genetic Algorithm and Direct Search toolbox.
We have also created additional resources for the instructor and for the user.
In addition to a solution manual that is available to instructors, we also provide a set

of PowerPoint slides covering the material presented in Chapters 1–7. For the user
of the book, we have created M files of all the numbered examples in each chapter.
These ancillary materials can be accessed from the publisher’s Web site.
E. B. MAGRAB
S. AZARM
B. BALACHANDRAN
J. H. DUNCAN
K. E. HEROLD
G. C. WALSH
College Park, MD


1
Introduction
Edward B. Magrab

1.1 Introduction 1
1.1.1 Organization of the Book and Its Goals 2
1.1.2 Some Suggestions on How to Use MATLAB 2
1.1.3 Book Notation Conventions 3
1.2 The MATLAB Environment 3
1.2.1 Introduction 3
1.2.2 Preliminaries—Command Window Management 5
1.2.3 Executing Expressions from the MATLAB Command Window—Basic
MATLAB Syntax 8
1.2.4 Clarification and Exceptions to MATLAB’s Syntax 11
1.2.5 MATLAB Functions 14
1.2.6 Creating Scripts and Executing Them from the MATLAB Editor 19
1.3 Online Help 29
1.4 The Symbolic Toolbox 32

1.5 Summary of Functions Introduced in Chapter 1 41
Exercises 42
The characteristics of the MATLAB environment and MATLAB’s basic syntax are
introduced.

1.1 INTRODUCTION
MATLAB, which derives its name from Matrix Laboratory, is a computing language
devoted to processing data in the form of arrays of numbers. MATLAB integrates
computation and visualization into a flexible computer environment, and provides
1


2

Chapter 1

Introduction

a diverse family of built-in functions that can be used in a straightforward manner to
obtain numerical solutions to a wide range of engineering problems.
1.1.1 Organization of the Book and Its Goals
The primary goal of this book is to enable the reader to generate readable, compact,
and verifiably correct MATLAB programs that obtain numerical solutions to a wide
range of physical and empirical models and display the results with fully annotated
graphics.
The book can be used in several ways:
• To learn MATLAB
• As a companion to engineering texts
• As a reference for obtaining numerical solutions to a wide range of engineering problems
• As a source of applications of a wide variety of MATLAB solution techniques

The level of the book assumes that one has some fluency in calculus, linear
algebra, and engineering mathematics, can employ the engineering approach to
problem solving, and has some experience in using mathematical models to predict
the response of elements, devices, and systems. These qualities play an important
role in creating programs that function correctly.
The book has two interrelated parts.The first part consists of Chapters 1–7, which
introduces the fundamentals of MATLAB syntax and commands and structured
programming techniques. The second part, consisting of Chapters 8–14, makes
extensive use of the first seven chapters to obtain numerical solutions to engineering
problems for a wide range of topics. In several of these topical areas, MATLAB
toolboxes are used extensively to minimize programming complexity so that one can
obtain numerical solutions to engineering problems of varying degrees of difficulty. In
particular, we illustrate the use of the Controls toolbox in Chapters 9 and 10, Simulink
in Chapter 10, the Optimization toolbox in Chapter 13, the Statistics toolbox in
Chapter 8, and the Symbolic toolbox in Chapters 1–5 and 9.
1.1.2 Some Suggestions on How to Use MATLAB
Listed below are some suggestions on how to use the MATLAB environment to
effectively create MATLAB programs.
• Write scripts and functions in a text editor and save them as M-files. This will save
time, save the code, and greatly facilitate the debugging process, especially if the
MATLAB Editor is used.
• Use the Help files extensively. This will minimize errors caused by incorrect
syntax and by incorrect or inappropriate application of a MATLAB function.
• Attempt to minimize the number of expressions comprising a program. This
usually leads to a trade-off between readability and compactness, but it can


×