0132634007 pdf 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.
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., 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 Introduction Edward B Magrab 1.1 1.2 1.3 1.4 1.5 2.7 xxi Introduction 1.1.1 Organization of the Book and Its Goals 1.1.2 Some Suggestions on How to Use MATLAB 1.1.3 Book Notation Conventions The MATLAB Environment 1.2.1 Introduction 1.2.2 Preliminaries—Command Window Management 1.2.3 Executing Expressions from the MATLAB Command Window—Basic MATLAB Syntax 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 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 112 Exercises 113 vii viii Contents Data Input/Output Edward B Magrab 3.1 3.2 3.3 3.4 3.5 3.6 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 144 Exercises 145 Program Flow Control Edward B Magrab 4.1 4.2 4.3 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 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 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 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 Exercises 809 For the acid titration, that is, when we are adding H + , we use Eq (14.11) and express the proton concentration as [H + ] = [H + ]i + y where [H + ]i is the initial proton concentration and y is the amount of acid added, usually HCl, which dissociates completely in water In this context, we let y 10-7 Thus, from Eq (14.11) [HCO3- ] = Kc1 [CO2]d [H + ]i + y y 10 - For the base titration, we use Eq (14.11) again, but combine it with the dissociation equation for water Kw = [H + ][OH - ] where Kw = 10-14 For the proton concentration, we obtain [H + ] = Kw Kw = [OH ] [OH - ]i + y where [OH - ]i is the initial hydroxyl concentration and y is the amount of base added, usually NaOH, which dissociates completely in water In this context, we let y 10-6 Thus, from Eq (14.11) [HCO3- ] = Kc1 [CO2]d A [OH - ]i + y B Kw y 10 - For the remaining parameter values, use the values given in Example 14.4 Section 14.2.3 14.7 Plot the saturation curve for oxygen binding to hemoglobin as given by either Eq (14.14) (or equivalently by the equation preceding Eq (14.28)) and the derivative of the total O2 concentration with respect to the dissolved O2 concentration as given by Eq (14.29) Let n = 2.34, C50 = 35.14 * 10 - M, and [Hb] = 0.0022 M 14.8 Typical values for blood are PCO2 = 33 - 45 mmHg, [HCO3- ] = 18 - 23 mM, and pH = 7.34 - 7.45 For PCO2 = 45 mmHg and pH = 7.4, use Eqs (14.7) and (14.8) to compute the bicarbonate concentration and compare it to the normal limits (Answer: [HCO3- ] = 21.24 mM, which is within the normal range) Section 14.2.4 14.9 Compare the numerical results from Example 14.5 for plug flow to the approximate solution given by C = Cin c1 + Da e N - 3(h - y) b xN f d Pe 14.10 In Example 14.5, replace the water with blood as the perfusion medium and keep the same flow rate and consider plug flow only The storage of bound oxygen influences the advection term such that Eq (14.18) becomes Pe 0CT,O2 0CO2 2CO2 = b 0CO2 xN 0yN 810 Chapter 14 Biological Systems: Transport of Heat, Mass, and Electric Charge where Pe is a constant and 0CT,O2>0CO2 is given by Eq (14.29) For the parameters appearing in Eq (14.29), use those given in Example 14.7 It will be found that the ability of blood to store oxygen in bound form cause the decrease in concentration along the bioreactor to be much less when using blood as compared to water Section 14.2.5 14.11 a Starting from Example 14.6, run Example_6 with K = and K = 25 * 10 - 10 and compare the results Note that with K = 0, the concentration is lower at the center of the tumor because in this case the metabolic sink term is constant throughout With K = 25 * 10 - 10, the metabolic sink term is reduced when the oxygen concentration is low b When K = 0, the solution to Eq (14.25) subject to the boundary conditions given by Eq (14.26) is given by c(x) = + © ( x - 1) Compare the numerical solution obtained in part (a) with this result Section 14.2.6 14.12 a Referring to Example 14.7, the mean outlet concentration is defined as Rc Rc 0 2p VC(z, r)rdr = A - (r/Rc)2 B C(z, r)rdr Cm(z) = VmA Rc where A is the cross-sectional area of the capillary and we have used the fact that Vmax/Vm = Using the results of Example 14.7, determine the mean outlet concentration at z = L (Answer: 45.2942 mM) b Perform a parametric study on the effect of the mass diffusivity parameters Dc and Dt to determine the sensitivity of the mean outlet concentration to these parameters Run the model with 10% changes in Dc and Dt using the combinations shown in Table 14.9 and determine the mean output concentration at each of these concentrations.The results are also shown in the table It is seen that the total transport is more sensitive to the tissue diffusivity This is an example where there are two transport resistances in series with one larger than the other such that the transport rate is “controlled” by one of the resistances In this case, the diffusion through the tissue TABLE 14.9 Parameter Values for Exercise 14.12 Dc (m2/s) -9 2.2 * 10 1.8 * 10 - * 10 - * 10 - Dt (m2/s) -9 * 10 * 10 - 1.1 * 10 - 0.9 * 10 - Cm (mM) 45.1111 45.5170 44.0989 46.6450 Exercises 811 controls the overall transport rate Thus, changes in that resistance have a larger overall effect on the total transport Section 14.3 14.13 Consider Eq (14.41), which is used to describe an axon subjected to a membrane potential Assume a membrane potential of -65 mV and zero initial conditions for each gating parameter In addition, assume that the membrane potential is held for ms at -65 mV and then suddenly increased to mV for ms before returning to -65 mV For these conditions, determine the steady-state values for n, m, and h, which are those values that these quantities have at 100 s (Answers: n = 0.31768, m = 0.05294, and h = 0.59611) 14.14 Using Example 14.9 as the starting point with a resting potential of -65 mV, compute the ion current Iion for step changes to a membrane potential of -50 mV, -25 mV, mV, and 25 mV and plot the results Apply the resting potential for ms before applying the step changes Let each step change remain constant for 16 ms before returning to the resting potential at 18 ms The entire simulation is to last for 20 ms The ion current Iion is determined from Eq (14.43) as Iion = gkn4(V - EK ) + gNam3h(V - ENa) + gL(V - EL) Use the values in Table 14.8 for the other parameters appearing in Eq (14.43) 14.15 The action potential is often described as “all or nothing.” Test this description by varying the stimulus and comparing the shape and magnitude of the resulting action potentials Start from the solution given in Example 14.10 and change the stimulation potential to 100 mV, 150 mV, 200 mV, and 250 mV For each of these cases, plot the resulting action potential on the same graph 14.16 One of the characteristics of the sodium channels is that they exhibit a refractory period where they will not respond until a certain time has elapsed To test this statement, start from the program given in Example 14.10 and modify it to provide the stimuli that are separated in time as follows Consider the following stimulus pairs: (1) a pulse that starts at ms and lasts for 0.1 ms and followed by another pulse that starts at 11 ms and lasts for 0.1 ms, and (2) a pulse that starts at ms and lasts for 0.1 ms followed by another pulse that starts at 12 ms and lasts for 0.1 ms The results should show that at 11 ms the response to the second pulse is severely stunted, whereas for the case where the second pulse is initiated at 12 ms, the response to the second pulse looks very similar to that of the first pulse 14.17 Some neurons fire repeated action potentials and encode information in the frequency of the firing An interesting characteristic of the Hodgkin–Huxley model of Section 14.3 is that under certain conditions, the equations will fire in a self-sustained pulse train after a single stimulation This can be shown by changing the maximum sodium conductance to one-half of its current value, that is, gk = 0.018 S/cm2, and running a simulation for 100 ms with a single stimulus at ms and duration of 0.1 ms The result should show a continuous train of action potentials firing with a period of approximately 18 ms Index @, 18, 187 see also Function handle A Ablation of tumor, 770 Accelerometer, 514 Acoustic source, radiation pattern from, 330 Airfoil, 653 See also Joukowski airfoil Amplitude response function, 464, 489, 519 Amplitude spectrum, 248 Animation, 307 Annotation to command window, 133 Anonymous function, see Function, user-created Apostrophe, 18 see also Matrix transpose and Strings Apple surface, 372 Area of polygon, 195 general shape, 208 812 Assignment operator, Astroid, 320 Astroidal ellipse, 371 Archimedean spiral, 320 Autopilot, control system for, 610 B Backslash (\), 18, 107 Baseball seam, 370 Beams, see Euler beam and Timoshenko beam Bearing, thrust, 254 Bicarbonate buffer system, 775 Bicuspid, 320 Bi-cylinder coordinate system, 323 Bioheat equation, 770 Biot number, 662 Blank line, removal of, space, 10, 18 Blasius boundary layer, 628, 672, 674 Block diagram,526, 542 Blood, properties of, 780 Index Bold text, 298 Bow curve, 371 Braces, 17 Brackets, 17 Butterfly, 320 C Cable, inextensible, 259 Cam, 336 Campbell diagram, 523 Capillary, see Krogh cylinder model Carbon dioxide transport in blood, 778 Carbonic acid titration curve, 777 Cardioid, 320 Cascaded system, 543 Cell, 141 see also Editor Chatter, see Machine tool chatter Coefficient of determination, 406 Colebrook formula, 252, 329, 621, 623 Colon, 17 notation, 54 Comma, 17 Comment, see Percentage sign Command history, clear, window, management of, Complex number, 11, 13 Compressibility factor, 251 Concho spiral, 370 Confidence intervals, 397 Contour, see Plot Controllability, 558 Controller design, tools for, 527 Controls toolbox, 524 Convection, natural, 214 Conversion, decimal-to-integer, 15 Convolution integral, evaluation of, 242 Cornucopia, 371 Correlation coefficient, 406, 441 Cross correlation, 198, 200 Cruise control, automotive, 609 813 Curvature, symbolic determination of, 37 Curve fitting, 464, 710, 713, 715 Cycloid, 320 Cylinders, intersecting, 370 Coulomb damping, 472 D Damkohler number, 782 Data entry, 135 Data files, creation of, 137 Design of experiments, 415 2k factorial, 424 multiple factor, 419 single factor, 415 Determinants, 101 Difference equations, 539 Differential equations, solution of, boundary value problems (bvp4c), 217 delay (dde23), 231 initial value problems (ode45), 212 parabolic-elliptic (pdepe), 233 symbolic solution, 244 Differentiation, symbolic, 33, 35, 35 Digital signal processing, 196 Directory path, selection of, 24 Dot operations, 11, 83, 157 Dumbbell, 320 E Edit menu, Editor, 3-5, 20 cell mode, 23 Effect, determination from a designed experiment, 427 Eigenvalues, three degree-of-freedom system, 102 Eight curve, 320 Electric circuit, 125 Emissivity, 688 Epicycloid, 320 Equally spaced values, generation of, 57 814 Equilibrium equations, chemical 776 Euler angles, 366 Euler beam, 221 impulse response of, 509 natural frequency of, 229 point loading, 226 uniformly loaded, 222 with overhang, 223 variable cross section, 227 Euler transformation matrix, 111 Execution, program, 24 Exponentially decaying sine wave, 192, 193, 209 F Factorial experiment, see Design of experiments Fast Fourier transform, 196 inverse, 196 Feedback, 526 positive, 593 stability of, 527 unity gain, 533 FFT, see fast Fourier transform Figure within figure, 304, 362 First-order system, 551 Fitting data with polynomials, 188 with splines, 190 Flow biological, 646 channel, water in, 250 external, 626 gas from tank, 262 laminar boundary layer, 630 pipes, in, 621, 670 open channel, 641 potential, 631, 651 turbulent, 622 viscous, 621 Flow field, uniform, 632 Fluid acceleration, 627 Folium, 320 Index Forced oscillation linear system, 462 nonlinear system, 478 Fourier series evaluation of, 10 single degree-of-freedom system, 466 Fourier transform, discrete, 196 Fourth-order system, control of, 557 Free oscillations linear system, 456 nonlinear system, 469 Frequency-response function, 456, 483 Froude number, 642 Function, MATLAB abs, 14, 16 acker, 570 acos, 14 acosh, 14 acot, 14 acoth, 14 acsc, 14 acsch, 14 airy, 16 alpha, 568, 571 angle, 16 anova1, 417, 418 anova2, 420, 421 anovan, 423 arx, 560 asec, 14 asech, 14 asin, 14 asinh, 14 atan, 14 atan2, 14, 467 atanh, 14 axes, 304 axis equal, 276 axis ij, 345 axis image, 288 axis vis3d, 355, 513 axis, 274, 275, 281, 345 bar, 283, 378 besseli, 16 besselj, 16, 96, 204, 664 Index besselk, 16 bessely, 16 beta, 15 binocdf, 384 binofit, 384 binoinv, 384 binopdf, 384, 385 binornd, 384 binostat, 384 bintprog, 709, 710 bode, 462, 560, 561, 566 box, 281, 345 boxplot, 372 break, 8, 166 bvp4c, 217, 223, 225, 226, 228, 230, 505, 630, 667, 674, 788, 793, 794 bvpinit, 217, 223, 225, 226, 228, 230, 505, 630, 667, 674, 788, 793, 794 c2d, 539, 540 case, 8, 154 ceil, 15, 313 celldisp, 142 cellstr, 143 char, 129, 141, 457, 470, 476, 799 chi2cdf, 384 chi2inv, 384 chi2pdf, 384 chi2rnd, 384 chi2stat, 384 clabel, 348 clc, 5, 27 clear, 5, 27 close, 27 collect, 39 colorbar, 351 colormap, 346, 391 compare, 560 complex, 16, 639 conj, 16, 58 connect, 543 continue, contour, 348, 640, 705 contour3, 349 contourf, 351 conv, 536 convhull, 286 815 cos, 14 cosd, 14 cosh, 14 cot, 14 cotd, 14 coth, 14 csc, 14 cscd, 14 csch, 14 cumsum, 88, 161, 278, 379 cylinder, 352 damp, 464, dblquad, 207, 211, 684 dcgain, 538, 573 dde23, 231 deblank, 130 delauney, 286 det, 102 detrend, 559, 560 deval, 217, 218, 231, 630, 667, 674, 788, 793, 794 diag, 68, 496, 498 diff, 34, 40, 194 disp, 26, 131 dot, 95 dsolve, 244 eig, 102, 496, 498 ellipke, 16 ellipsoid, 353 else, 8, 151 elseif, 8, 151 end, 8, 151, 154, 162 eps, 15 erf, 16 erfc, 16, 661 error, 153 eval, 139 exp, 14 expint, 16, 774 expm1, 14 eye, 16, 774 factor, 38 factorial, 14 fcdf, 384, 404 feedback, 533, 537, 538, 561, 565, 579, 582, 586, 593, 595 816 Function, MATLAB (Continued) feval, 186 ffn2, 426 fft, 196, 479 fgoalattain, 738, 741 figure, 267 fill, 294, 317, 461, 568, 571 fill3, 355, 357 find, 62, 63, 73, 160, 312, 461, 640 findstr, 129, 138 finv, 384, 400 fix, 15 fliplr, 79, 128 flipud, 80, 317 floor, 15, 555, 749 fminbnd, 235, 312, 619, 720, 721, 734 fmincon, 722, 723, 726, 729 fminimax, 492, 736, 740 fminsearch, 493, 711, 713 fminunc, 710, 711 for, 8, 151, 155 format, 6, 7, fpdf, 384 fprintf, 27, 132 frnd, 384 fseminf, 732, 734 fsolve, 238 fstat, 384 function, 8, 175 fzero, 202, 461, 619, 626, 643, 645, 691, 777 ga, 743, 746, 750 gamma, 16 gamultiobj, 743, 747 gaoptimset, 744, 746, 747, 750 gca, 301 geomean, 379 getframe, 307 global, 8, 177, 179, 180, 745 grid, 281, 345 help, 29, 176 hidden, 342 hist, 378 histfit, 391 hold, 269 humps, 237 Index i, 11, 15 iddata, 558, 560 ident, 558 if, 8, 151 ifft, 186 ilaplace, 36, 489 imag, 16, 571, 599 image, 288 impulse, 462, 487, 548, 856 imread, 288 inf, 15, 35, 36, 723, 741 initial, 550, 604 inline, 184, 240 input, 25, 135 int, 35 int2str, 131 interp1, 192, 459, 564, 692 inv, 104, 108, 600, 601 isempty, 506 j, 11, 15 legend, 292 legendre, 16 length, 55 limit, 35 linprog, 706, 707, 708 linsolve, 107 linspace, 57 load, 137 log, 14 log10, 14 log1p, 14 loglog, 283 logncdf, 384 lognfit, 384 logninv, 384 lognpdf, 384 lognrnd, 384 lognstat, 384 logspace, 384 lqe, 560, 570 lqr, 560, 570, 571, 603, 604 lsim, 548 lsqcurvefit, 464, 714, 715 lsqnonlin, 715, 717, 718 magic, 17 maineffectsplot, 423 Index margin, 561 matlabFunction, 240 max, 16 mean, 16, 63, 378, 388 median, 16, 379 mesh, 341 meshc, 347 meshgrid, 76, 278 meshz, 347 min, 16, 63 minreal, 554, 593, 600, 601 mode, 16 movie, 308 movie2avi, 308 NaN, 15, 179 nargin, 599 normcdf, 384, 389 normfit, 384, 388 norminv, 384, 389 normpdf, 384, 389 normplot, 391, 408, 418, 432 normrnd, 384 normspec, 389 normstat, 384 num2str, 130 numden, 37 nyquist, 560 ode45, 212, 449, 457, 459, 470, 473, 477, 479, 486, 487, 494, 643, 691, 692, 803, 806 odeset, 213, 449, 473, 792, 806 ones, 67 optimset, 202, 218, 492, 711, 713 otherwise, 8, 154 parallel, 544 patch, 295 pdepe, 233, 621, 646, 666, 670, 771, 784, 792 persistent, pi, 15 pie, 286 pie3, 286 place, 570, 573 plot, 269 plot3, 338, 491 plotyy, 283, 817 poisscdf, 384 poissfit, 384 poissinv, 384 poisspdf, 384, 387 poissrnd, 384 poissstat, 384, 387 pol2cart, 95 polar, 310 pole, 537, 538, 554, 561, 564, 584, 591, 593, 599 poly, 205 polyarea, 195 polyconf, 405, 407 polyfit, 188, 311, 405, 407, 774 polyval, 188, 311, 408 prctile, 383 pretty, 37 primes, 14 print, 269 prod, 379 quadl, 207, 511, 616 quadprog, 730, 731 rand, 560, 774 randn, 313 range, 379 rank, 497 raylcdf, 384 raylfit, 384 raylinv, 384 raylpdf, 384 raylrnd, 384 raystat, 384 rcoplot, 413 real, 16, 33, 571, 599 realmax, 15 realmin, 15 reg, 570 regress, 411, 412 repmat, 76 return, 8, 178 ribbon, 348 rlocfind, 570, 577, 580, 585, 593, 595, 601 rlocus, 568, 570, 576, 577, 580, 585, 593, 595, 601 roots, 205 818 Function, MATLAB (Continued) round, 15, 313 save, 139 sec, 14 secd, 14 sech, 14 semilogx, 283 semilogy, 283 series, 543 set, 271 sgrid, 568, 572, 576, 585 shading, 355 sign, 14, 475, 477 simple, 38, 40, 106 simplify, 41 simulink, 544, 587 sin, 14 sind, 14 sinh, 14 size, 66 skewness, 383 solve, 243 sort, 61, 103, 143, 313, 498 sortrows, 143 sphere, 353 spline, 190, 459, 615 sprintf, 135, 140 sqrt, 10, 14 ss, 530, 531, 547, 576, 584, 591, 599 ssbal, 547 ssdata, 532, 544, 570, 571, 573, 603, 604 stairs, 283 std, 16, 378, 388 stem, 283 step, 464, 487, 534, 537, 548, 551, 556, 558, 571, 573, 579, 596 strcmp, 130, 487 strtrim, 130 subplot, 267, 316 subs, 36 sum, 88, 195, 513 surf, 341 surfc, 347 surfnorm, 348 switch, 8, 151, 154, 508 Index syms, 33, 106, 316 tan, 14 tand, 14 tanh, 14 taylor, 36 tcdf, 384, 402 text, 291 tf, 462, 530, 536, 547, 552, 558, 566, 580, 582, 586, 593, 595, 600 tfdata, 537, 587 tinv, 384 title, 291 tpdf, 384 trace, 451 trapz, 193 triplot, 286, 287 trnd, 384 tstat, 384 ttest, 402, 403 ttest2, 402, 403 tzero, 538, 592, 595 var, 16, 400 vartest, 402 vartest2, 402, 404 vectorize, 240, 489 view, 353 voronoi, 286 vpa, 33, 34, 489 waterfall, 347 wblcdf, 384, 395 wblfit, 384, 395 wblinv, 384, 395 wblpdf, 384, 394 wblplot, 305 wblrnd, 384 wblstat, 384, 394 while, 8, 151, 162 whos, xlabel, 291 xlim, 274, 275 xlsread, 143 ylabel, 291 ylim, 274, 275 zeros, 68, 156 zgrid, 582 Index zlabel, 339 zpk, 530, 538, 547, 577, 580, 582 zscore, 389 ztest, 402 Function, user-created, 172, 175, 186, 201 anonymous, 175, 183 debugging, 174, file, 173, 175 inline, 175, 184 interface, 175 length of, 174 naming of, 174 subfunction, 175, 181 transfer of data with, 188 Function handle, 183 G Gate, planar, forces on, 616 Gear, 320 reducer, 727 tooth, 324 worm, 262 lead angle, 327 Genetic algorithm, optimization with, 742 Genetic Algorithm and Direct Search toolbox, 742 Gingerbread man, 323 Graphs, see also Surfaces annotation, 291 axes labels, 291 Greek letters, 296 legend, 292 mathematical symbols, 296 table of, 299 style, 299, 300 text, 291 title, 291 attributes, alteration of, 299 management of, 266 functions, 267 special purpose, 281 819 H Hamming function, 198 Handle, see Function handle Heat flux, 670, 674, 679 Heat transfer biological tissue, 770 conduction, 660 convection with, 662 heat source, with, 664 convection, 668 natural, 677 radiation, 682 enclosure, within, 687 transient, 690 Help, 29 Henry’s law, 778 Hierarchy, mathematical operations, 10 Hill model, 780 Histogram, 378 unconventional, 313 Hodgkins-Huxley action potential, 804 gating parameters, 797 display of, 799 neuron model, 796 step function input to, 802 Hydrostatics, 614 Hyperbolic helicoid, 372 Hypocycloid, 320 Hypothesis testing, 401 I Index, 29, 31 Infinite impulse response (IIR), 541 Initial conditions, 448, 457, 459, 469, 473, 476 inline, see Function, user-created and Function, MATLAB Integration numerical of a function, 207 using data, 193 symbolic, 33-35 820 Interface, see Function, user-created Interpolation of data, 192 Italic text, 298 J Joukowski airfoils, 636, 654, 655 transformation, 636 K Keywords, plotting, 276 Krogh cylinder model, 789 L Laplace equation, 97, 631 Laplace transform, 456, 482, 535 symbolic inverse, 37, 241 Lead control, 567, 568, 569, 576, 577, 589 Legend, see Plot characteristics Lemniscate, 320 Limits, symbolic, 35 Linear programming, 706 Logarithmic decrement, 455 Logarithmic spiral, 320 Logical operator, 148 Lognormal distribution, 438 Loop for, 15 while, 162 Loss factor, 333 LQG controller, 603 M M file, 173 Machine tool chatter, 232, 460 Manning equation, 642 Matrix addition and subtraction, 81, 92 column augmentation, 81 creation of, 64, 74, 76 Index diagonal, 52, 68 identity, 52, 69 inverse, 104 symbolic, 106 manipulation of elements, 69-73, 75 maximum value, 73 minimum value, 73 multiplication, 92 column vector and row vector, 95 row vector and column vector, 94 row vector and matrix, 99 null, 68 row augmentation, 82 square, 52 transpose, 10, 53 with complex elements, 67 Mean, 377 Mean square, 416, 420 Michaels-Menten constant, 783 model, 782, 786 M-Lint, 22 Minimum of a function, 235 Missile, control system for, 608 Möbius strip, 371 Mode shape circular membrane, 96 three degree-of-freedom system, 496 Moment of inertia, principal, 450 Moody diagram, 330 Multiple-valued functions, 203 N Natural frequency eight degree-of-freedom system, 521 Euler beam, 229 with interior spring, 259-261 four degree-of-freedom system, 497 three degree-of-freedom system, 496, 520 Timoshenko beam, 499 two degree-of-freedom system, 484 Index Nested structure, 149 Nonlinear equations, numerical solutions of, 238 Nonminimum phase, 557, 595 Notation convention, book, Notch controller, 577 Notch filter, 608 O Observability, 558 Operators, arithmetic, 10 Optimization toolbox, 702 Orbital motion, 447 Overloading, 18 Overshoot, 525, 528, 563, 565 Oxygen concentration, 782, 785, 789 supply to tumor, 786 transport in blood, 779 P Pappus chain, 331 Parallel connection of systems, 543 Parentheses, 17 Pareto frontier, 736, 740, 748 Pendulum absorber, 215 inverted, 256 planar, 446 Percentage sign, 17, 18, 23 Percentile, 383 Period, 17 pH, 775 Phase portrait, see Phase space Phase space, 457, 472, 474, 555 Plant, 576 Plate, circular, 260 natural frequencies, 372 Plot characteristics, changing, 270-273 axes, 300 filling regions, 294 legend, 301 821 line styles, 300 shading, 355 transparency, 295 circles, 276 multiple, 276, 277 contour, 347 curves combined with surface, 342 multiple, 277, 279-281, 311 spatial, 338 interactive, 306 lines, 270, 273-276 points, 270, 271 Polar plot, 309 Polar to Cartesian coordinates, 87, 95 Power screw, efficiency of, 326 Prandtl number, 673 Pre-allocation, array, 155 Preferences, 7, 22 Pressure coefficient, 637 Pressure distribution in atmosphere, 615 Principal stress, 249 Probability distribution, 383 continuous, 387 normal, 388 sine wave, 322 Weibull, 394 discrete, 383 binomial, 384 Poisson, 386 Process capability ratio, (PCR), 439 Production planning, 707, 741 Proportional controller, 567, 569, 577 Proportional derivative (PD) controller, 584 Proportional integral derivative (PID) controller, 586 R Radiation pattern, acoustic, 332 Radiosity, 688 Reference signal, 526 Regression equation, 408, 428, 431 linear, 404 822 Regression (Continued) multiple, 408 simple, 404 Relational operators, 14, 15, 149 Reliability, 437 Reservoir, 256, 616, 618 connected, 624 discharge from, 644, 655 oscillations in, 648 Residuals, 406, 410 standardized, 442 studentized, 442 Reynolds number, 669 Rigid body, stability of, 451 Rise time, 563, 565 Root locus, 567 Roots polynomial, 205 transcendental function, 202 S Sample time, discrete, 541 Save and Run, 19 Saving program, 25 Scalar versus array, 11 Scripts creating, 19 executing, 19 Search, 31, 32 Seashell, 371 Second-order system, 554, 556 Seismometer, 515 Semicolon, 9, 17 Series connection of systems, 543 Servomotor, 525, 531 Settling time, 564 Shell, cylindrical, 264 buckling coefficients, 334 natural frequencies, 335 Similarity solution, 629, 672, 677 SIMULINK, 526, 542, 586 Single degree-of-freedom system, 39, 209, 237, 305, 454 Index Sink, 632 Slider-crank mechanism, animation of, 308 Source, 632 Spherical helix, 370 Spherical spiral, 370 Spring Belleville, 324 helical, 723 nonlinear, 469, 478 piece-wise linear, 475 two-spring system, 703 Square, drawing of, 317 Stability, 561 State-space form, 455, 484 model, 530 Statistics toolbox, 445 Stream function, 629, 631, 639, 673, 677, 681 Streamlines, 633, 639 Stress concentration factor, 247 Strings creating, 127 concatenation of, 128 Subfunction, see Function, user-created Subscripts, see Graph Substitution, symbolic, 36 Sum-of-squares, 416, 419, 420 Summation, 88 Super ellipse, 320 Superscripts, see Graphs Surfaces, plotting of, 341 cylindrical, 352 ellipsoidal, 353 spherical, 353 transparency of, 355 Suspension system, 606, 610 Symbolic expression, conversion to function, 240 Symbolic toolbox, 33 Syntax, basic MATLAB, System identification, 558 System of equations, numerical solution of, 108 symbolic solution of, 243 Index T Taguchi, 436 Taylor series, 583 symbolic, 33, 36 Thermal conductivity, determination of, 773 Timoshenko beam natural frequencies, 499 static displacement, 261 Toroidal spiral, 370 Torus, 366 figure eight, 371 Transfer function, 483, 516 Transfer function representation, 535 Transpose, see Matrix and Vector Truss, two bar, 745, 747, 748 Two degree-of-freedom system, 157, 481 amplitude response, 489 base excitation, 493 frequency response, 315 impulse response, 486 initial velocity, 485, step response, 486 U Unit step function, 150 V Variable precision arithmetic, 33, 34 Variance, 378 823 Vector accessing elements of, 59 column, 53 creation, 53 manipulation of elements, 59 row, 52 transpose, 53, 66 complex values, with, 58 Vibrations cable, 250 cantilever with mass, 250 circular plate, 250 clarinet reed, 257 cylindrical shell, 264 forced, 254 membrane, 249 platform, optimization of, 738 string, 249 Vibration absorber, 491 View factor, 682 View menu, von Mises stress, 376 Vortices, 632 W Weighting function, 197 Window default, command, Wire-frame box, 339 Workspace, 3, clear, .. .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. .. closing the command history, current directory, and workspace windows and opening the Editor 1.2.2 Preliminaries—Command Window Management During any MATLAB session—that is, during any time until... expressions in the command window can be removed by going to the Edit pull-down menu at the top of the MATLAB command window and selecting Clear Command Window, which clears the MATLAB command window, but