1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

MATLAB what every engineer sh adrian b brian

448 141 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

WHAT EVERY ENGINEER SHOULD KNOW ABOUT MATLAB® ® and Simulink WHAT EVERY ENGINEER SHOULD KNOW A Series Series Editor* Phillip A Laplante Pennsylvania State University What Every Engineer Should Know About Patents, William G Konold, Bruce Tittel, Donald F Frei, and David S Stallard What Every Engineer Should Know About Product Liability, James F Thorpe and William H Middendorf What Every Engineer Should Know About Microcomputers: Hardware/Software Design, A Step-by-Step Example, William S Bennett and Carl F Evert, Jr What Every Engineer Should Know About Economic Decision Analysis, Dean S Shupe What Every Engineer Should Know About Human Resources Management, Desmond D Martin and Richard L Shell What Every Engineer Should Know About Manufacturing Cost Estimating, Eric M Malstrom What Every Engineer Should Know About Inventing, William H Middendorf What Every Engineer Should Know About Technology Transfer and Innovation, Louis N Mogavero and Robert S Shane 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 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 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 40 What Every Engineer Should Know About Software Engineering, Phillip A Laplante 41 What Every Engineer Should Know About Developing Real-Time Embedded Products, Kim R Fowler 42 What Every Engineer Should Know About Business Communication, John X Wang 43 What Every Engineer Should Know About Career Management, Mike Ficco 44 What Every Engineer Should Know About Starting a High-Tech Business Venture, Eric Koester 45 What Every Engineer Should Know About MATLAB® and Simulink®, Adrian B Biran with contributions by Moshe Breiner WHAT EVERY ENGINEER SHOULD KNOW ABOUT MATLAB ® and Simulink ® Adrian B Biran With contributions by Moshe Breiner Boca Raton London New York CRC Press is an imprint of the Taylor & Francis Group, an informa business MATLAB® and Simulink® are trademarks of The MathWorks, Inc and are used with permission The MathWorks does not warrant the accuracy of the text of exercises in this book This book’s use or discussion of MATLAB® and Simulink® software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB® and Simulink® software CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2010 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: 20140514 International Standard Book Number-13: 978-1-4398-1023-1 (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 Dedicated to Suzi, Mihal, Paul and Zohar Contents Preface I xv Introducing MATLAB Introduction to MATLAB 1.1 Starting MATLAB 1.2 Using MATLAB as a simple calculator 1.3 How to quit MATLAB 1.4 Using MATLAB as a scientific calculator 1.4.1 Trigonometric functions 1.4.2 Inverse trigonometric functions 1.4.3 Other elementary functions 1.5 Arrays of numbers 1.6 Using MATLAB for plotting 1.6.1 Annotating a graph 1.7 Format 1.8 Arrays of numbers 1.8.1 Array elements 1.8.2 Plotting resolution 1.8.3 Array operations 1.9 Writing simple functions in MATLAB 1.10 Summary 1.11 Examples 1.12 More exercises 3 10 10 13 15 16 18 20 21 22 22 23 24 27 31 34 42 Vectors and matrices 2.1 Vectors in geometry 2.1.1 Arrays of point coordinates in the plane 2.1.2 The perimeter of a polygon – for loops 2.1.3 Vectorization 2.1.4 Arrays of point coordinates in solid geometry 2.1.5 Geometrical interpretation of vectors 2.1.6 Operating with vectors 2.1.7 Vector basis 2.1.8 The scalar product 2.2 Vectors in mechanics 47 48 48 52 55 56 61 63 65 66 69 ix Applications in the frequency domain 413 Bode plot Magnitude, db 50 −50 −100 −150 −3 10 −2 10 −1 10 10 10 10 10 Phase, degrees −50 −100 −150 −200 −3 10 −2 10 −1 10 10 Frequency, rad/s 10 10 10 FIGURE 12.8: Bode diagram of mass-damper-spring system T = 1 = ms2 + cs + k 2s + 0.4s + 0.1 To calculate and plot the Bode diagram write a file, MyBode.m, whose contents are shown below The numerator of the transfer function is noted pnum, and the denominator, pden The logarithmic scale of frequencies is obtained with the command logspace, and the logarithmic x−axis, with the command semilogx %MYBODE Bode diagram of mechanical mass-spring-damper system % define system parameters m = 2; % mass, kg c = 0.4; % damping, Ns/m k = 0.1; % spring constant, N/m disp(’Own frequency’) sqrt(k/m) % define transfer function pnum = [ 0 ]; % numerator pden = [ m c k ]; % denominator % calculate magnitudes, decibels om = logspace(-2.5, 2.5); % frequency scale, rad/s s = i*om; 414 What every engineer should know about MATLAB and Simulink ol = polyval(pnum, s)./polyval(pden, s); olmag = 20*log10(abs(ol)); % calculate phase, degrees olpha = 180/pi*angle(ol); % plot magnitude curve subplot(2, 1, 1) semilogx(om, olmag, ’k-’) grid ylabel(’Magnitude, db’) title(’Bode plot’) % plot phase curve subplot(2, 1, 2) semilogx(om, olpha, ’k-’) grid xlabel(’Frequency, rad/s’) ylabel(’Phase, degrees’) The resulting plot is shown in Figure 12.8 Before concluding this section, we mention that the Control System Toolbox and the Signal Processing Toolbox contain a function, mag2db, for converting magnitudes to decibels, and another function, db2mag, for the inverse conversion For example, check that the result of 20*log10(0.4 equals, indeed, mag2db(0.4) 12.8 Summary The commands introduced in this chapter include fft - above X = fft(x) calculates the discrete Fourier transform (DFT) of x using the fast Fourier algorithm ifft - above x4 = ifft(X4) returns in x4 the inverse Fourier transform of X4 logspace - above om = logspace(-2.5, 2.5) generates a row vector, om, containing 50 logarithmically spaced frequency values ranging from 10−2.5 to 102 psd - a function that belongs to the Signal Processing Toolbox; it produces a power spectral density, or PSD, estimate round - round(x) rounds the elements of x to the nearest integers semilogx - produces a logarithmic x−axis Applications in the frequency domain 415 sort - above [spow, spos] = sort(pow) returns in spow the elements of pow sorted in increasing order, and in spos, their indices spectrum.welch - a function that belongs to the Signal Processing Toolbox; it produces a power-estimate object by the Welch method 12.9 Exercises Exercise 12.1 Ratios to decibels Starting from the definition of the decibel find the number of dB corresponding to the ratios 0.5, 10, and 25 If you have access to the Control System Toolbox or the Signal Processing Toolbox, repeat the exercise with the function mag2db Exercise 12.2 Decibels to ratios Starting from the definition of the decibel find the ratios corresponding to the 10, 68, and 120 dB If you have access to the Control System Toolbox or the Signal Processing Toolbox, repeat the exercise with the function db2mag Answers to selected exercises Chapter Exercise 2.8 For example, P1 P2 = Q1 Q2 = 2.2361 Exercise 2.9 Q3 Q2 10 R3 R2 Q1 y R1 P2 P3 P1 −2 10 12 x FIGURE 1: P1 P2 P3 P1 , initial Q1 Q2 Q3 Q1 , translation first R1 R2 R3 R1 , rotation first Exercise 2.10 The results, rounded up to two digits, are shown in Table 417 418 What every engineer should know about MATLAB and Simulink Table 1: Weight data of container ship Mass, t VCG, m LCG, m Lightship Deadweight Full load 12165 25670 37835 10.53 10.98 10.83 92.12 103.46 99.82 Chapter Exercise 3.2 A1 = [ 1; l1 ]; B1 = F*[ 1; l2 ]; X1 = A1\B1, R1y = X1(1) R2y = X1(2) A2 = [ cosd(alpha) cosd(beta); sind(alpha) sind(beta) ]; B2 = [ 0; F ]; X2 = A2\B2, T1 = X2(1), T2 = X2(2) T1*cosd(alpha), T2*cosd(beta) Exercise 3.3 Define P1 = [ 1 ] and calculate P2 = conv(P1, P1), P3 = conv(P1, P2 Chapter Exercise 4.2 The area is 1.8333 Chapter Exercise 5.5 While 0.01 and 0.02 not belong to the set of computer numbers, 0.03125, equal to 2−5 , is a computer number Chapter Exercise 6.1 weight = 55446.12 m · kg · s−2 Answers to selected exercises Exercise 6.5 function r = ohm2S(p) % calculates conductance corresponding to given resistance if (p.unit == ’ohm’) Value = 1/p.value; Unit = ’S’; r = ElQuant1(Value, Unit); else errordlg(’Argument not a resistance’, ’Input error’) end % of conditional construct end % of ohm2S R1 = ElQuant1(2, ’ohm’); R2 = ElQuant1(3, ’ohm’); Req = S2ohm(ohm2S(R1) + ohm2S(R2)) Req = 1.2 ohm Chapter Exercise7.7 cos(z1 + z2) - cos(z1)*cos(z2) + sin(z1)*sin(z2) ans = 3.5527e-015 +3.1086e-015i sin(z1 + z2) - sin(z1)*cos(z2) - cos(z1)*sin(z2) ans = -2.6645e-015 +5.3291e-015i Chapter Exercise 8.2 L = 22.1035 419 420 What every engineer should know about MATLAB and Simulink Chapter Exercise 9.2 1) Write the following function to a file derv2a.m function wd = derv2a(t, w) % example of linear differential equation wd = -(1.2 + sin(10*t))*w; and produce the solution with the commands h = @derv2a; [ t, w ] = ode23(h, [ t0 tf ], w0); >> plot(t, w, ’k-’), grid 2) Write the following function to a file derv2b.m function wd = derv2b(t, w) % example of linear differential equation % in the form required by ODE3 and ODE45 wd = (cos(t) - w/(1 + t^2))/3; and produce the solution with the commands tspan= [ ]; w0 = 1; h = @derv2b; [ t, w ] = ode23(h, tspan, w0); plot(t, w, ’k-’), grid Chapter 10 Exercise 10.1 The conic section is a parabola, as shown in Figure Answers to selected exercises FIGURE 2: The conic section is a parabola Chapter 11 Exercise 11.1 See Figure on next page Chapter 12 Exercise 12.2 r = 10^(68/20) r = 2.5119e+003 db2mag(68) ans = 2.5119e+003 421 422 What every engineer should know about MATLAB and Simulink φ(0) = π/3, dotφ(0) = 0.1 1.5 Simulink output Linear model 0.5 −0.5 −1 −1.5 t, seconds 10 FIGURE 3: Comparing the nonlinear and the linear model of the pendulum Bibliography Abate, M 1996 Geometria, Milano, McGraw-Hill Anonymous 1992 What every computer scientist should know about floating point-arithmetics, Revision A, http://docs.sun.com/app/docs/doc/800-7895/6hos0aou1?a =view Anonymous 2000 The NIST reference constants, units and uncertainty, Physics Laboratory of NIST, http:/physics.nist.gov/cuu/Units Anton, H., and Rorres, C 2005 Elementary linear algebra – Application version, Anton Textbooks, Inc Banchoff, T, and Wermer, J 1983 Linear algebra through geometry, New York: Springer-Verlag, Undergraduate Texts in Mathematics Biran, A and Breiner, M 1995 MATLAB for engineers, Harlow, England: Addison-Wesley Biran, A and Breiner, M 1999 MATLAB for engineers, Harlow, England: Addison-Wesley Biran, A and Breiner, M 2002 MATLAB for engineers, Harlow, England: Pearson Education Biran, A and Breiner, M 2009 MATLAB pour l’ing´enieur – Version 7, 2nd ed., Paris: Pearson Education France Broch, J.T 1984 Mechanical vibration and shock measurements, 2nd ed., 4th reprint, Glostrup: K Larsen & Søn A/S Cooley, J.B., and Tukey, J.W 1965 An algorithm for the machine computation of complex Fourier series, Mathematics of Computation, 19, April, pp 297-301 Colonna, J-F 2006 Les calculs flottants sont-il fiables? http://www.lactamme.polytechnique.fr ´ ements d’informatique — Informatique et d´emarche de Corge, C 1975 El´ l’esprit, Paris: Larousse Davis, M 2000 The universal computer — The road from Leibniz to Turing, New York: W.W Norton and Company Dorf, R.C., and Bishop, R.H 1992 Modern control systems, 11th ed, Upper Saddle River, NJ: Pearson - Prentice Hall Duncan, M 2000 Applied geometry for computer graphics and CAD, London: Springer Emerson, W.H 2008 On quantity calculus and units of measurement, Metrologia, vol 45, pp 134-8 423 424 What every engineer should know about MATLAB and Simulink GAO (General Accounting Office) 1992 GAO report : Patriot missile defense — System failure at Dhahran Saudi Arabia, http://www.fas.org/spp/starwars/gao/im92026.htm Gerald, C.F and Wheatley, P.O 1994 Applied numerical analysis, 2nd ed., Reading-MA, Addison-Wesley Giordano, R.R., and Weir, M.D., 1991 Differential equations – A modeling approach, Reading, MA: Addison-Wesley Harel, D 2003 Computers Ltd — What they really can’t do, revised paperback edition, Oxford University Press German edition 2002, Italian 2002, Chinese 2003, Hebrew 2004 Harel, D., with Feldman, Y 2004 Algorithmics: The spirit of computing, Reading, MA: Addison Wesley Hebrew edition 1991, Dutch 1989, Polish 1992, 2001 Hofstadter, D.R 1979.Gă odel, Escher, Bach: an eternal golden braid, New York: Vintage Books Hultquist, P.F 1988 Numerical methods for engineers and computer scientists, Menlo Park, CA: The Benjamin/Cummins Publishing Company Institute of Electrical and Electronics Engineers 1985 IEEE standard for binary floating-point arithmetic (ANSI/IEEE Std 754-1985), New York: IEEE New edition 754-2008, IEEE Standard for Floating-Point Arithmetic See also Wikipedia, the entry IEEE 754-2008 Kahaner, D., Moler, C., and Nash, S 1989 Numerical methods and software, Englewood Cliffs, NJ: Prentice Hall Penrose, R 2004 The road to reality – A complete guide to the laws of the universe, London: Jonathan Cape Schneider, P.J and Eberly, D.H 2003 Geometric tools for computer graphics, Amsterdam: Morgan Kaufmann Publishers Shampine, L.F., and Reichelt, M.W (no date indicated) The MATLAB ODE suite, available in PDF form at http://www.mathworks.com/access/helpdesk/help/pdf_doc/ otherdocs/ode_suite.pdf Skeel, R 1992 Roundoff error and the Patriot missile, extract from SIAM News, July 1992, Vol 25, No 4, p.11, http://www.siam.org/siamnews/general/patriot.thm Smith, S 2006, MATLAB advanced GUI development, Indianapolis: Dog Ear Publishing Spiegel, M., and Liu, J 2001 Mathematical handbook of formulas and tables, Schaum’s Easy Outline of Mathematical Handbooks, New York: McGrawHill Standish, T.A 1994 Data structures, algorithms, and software principles, Reading, MA: Addison-Wesley Taggart, R., editor 1980 Ship design and construction, N.Y: SNAME Bibliography 425 Toich, S and Roberts, E 1998 The Patriot missile failure in Dhahran: Is software to blame?, http://shelley.toich.net/rojects/CS201/patriot.html Webster 1990 Webster’s ninth new collegiate dictionary, Springfield, MA: Meriam-Webster Inc Wood, A 1999 Introduction to numerical analysis, Harlow, England: Addison-Wesley Documentation provided by The MathworksTM can be downloaded from http://www.mathworks.com/access/helpdesk/help/techdoc/ We recommend especially: MATLAB - Getting Started Guide ControlSystemToolboxTM - Getting Started Guide Simulink - Getting Started Guide SymbolicMathToolboxTM - User’s Guide ... Every Engineer Should Know About Starting a High-Tech Business Venture, Eric Koester 45 What Every Engineer Should Know About MATLAB and Simulink®, Adrian B Biran with contributions by Moshe Breiner... 34 What Every Engineer Should Know About Concurrent Engineering, Thomas A Salomone 35 What Every Engineer Should Know About Ethics, Kenneth K Humphreys 36 What Every Engineer Should Know About... Komzsik 39 What Every Engineer Should Know About Excel, Jack P Holman 40 What Every Engineer Should Know About Software Engineering, Phillip A Laplante 41 What Every Engineer Should Know About Developing

Ngày đăng: 02/11/2017, 11:03

Xem thêm:

TỪ KHÓA LIÊN QUAN