ebook img

Learning MATLAB PDF

111 Pages·2009·0.97 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Learning MATLAB

Learning MATLAB Learning MATLAB Tobin A. Driscoll University of Delaware Newark, Delaware Society for Industrial and Applied Mathematics Copyright ©2009by the Society for Industrial and Applied Mathematics (SIAM) 10 9 8 7 6 5 4 3 2 1 All rights reserved. Printed in the United States of America. No part of this book may be reproduced, stored, or transmitted in any manner without the written permission of the publisher. For information, write to the Society for Industrial and Applied Mathematics, 3600 Market Street, 6th Floor, Philadelphia, PA 19104-2688 USA. Cover photo by John Pelesko and Tobin Driscoll. Photo taken in the Modeling, Experiment, and Computation Lab at the University of Delaware (www.math.udel.edu/MECLAB). Trademarked names may be used in this book without the inclusion of a trademark symbol. These names are used in an editorial context only; no infringement of trademark is intended. Maple is a registered trademark of Waterloo Maple, Inc. Mathematicais a registered trademark of Wolfram Research, Inc. MATLAB and the Optimization Toolbox are registered trademarks of The MathWorks, Inc. For MATLAB product information, please contact The MathWorks, Inc., 3 Apple Hill Drive, Natick, MA 01760-2098 USA, 508-647-7000, Fax: 508-647-7001, [email protected], www.mathworks.com. Windows is a registered trademark of Microsoft Corporation in the United States and/or other countries. Word is a trademark of Microsoft Corporation in the United States and/or other countries. Library of Congress Cataloging-in-Publication Data Driscoll, Tobin A. (Tobin Allen), 1969- Learning MATLAB / Tobin A. Driscoll. p. cm. Includes index. ISBN 978-0-898716-83-2 1. Mathematics--Data processing. 2. MATLAB. I. Title. QA76.95.D75 2009 620.001'51--dc22 2009008516 is a registered trademark. To Jen, Luke, and Adam, who are my greatest teachers. (cid:2) “matlabbook” (cid:1) (cid:1) 2009/5/27 pagevii (cid:1) (cid:1) Contents ListofFigures ix ListofTables xi Preface xiii 1 Introduction 1 1.1 Thefifty-centtour . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Graphicalversuscommand-lineusage . . . . . . . . . . . . 3 1.3 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Basiccommandsandsyntax . . . . . . . . . . . . . . . . . . 4 1.5 Savingandloadingwork . . . . . . . . . . . . . . . . . . . 6 1.6 ThingsaboutMATLABthatareverynicetoknow, butwhichoftendonotcometotheattentionofbeginners . . 7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 ArraysandMatrices 11 2.1 Buildingarraysandmatrices . . . . . . . . . . . . . . . . . 12 2.2 Referencingelements . . . . . . . . . . . . . . . . . . . . . 14 2.3 Matrixoperations . . . . . . . . . . . . . . . . . . . . . . . 18 2.4 Arrayoperations . . . . . . . . . . . . . . . . . . . . . . . . 20 2.5 Sparsematrices . . . . . . . . . . . . . . . . . . . . . . . . 23 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3 ScriptsandFunctions 27 3.1 Usingscriptseffectively . . . . . . . . . . . . . . . . . . . . 28 3.2 Functionsandworkspaces . . . . . . . . . . . . . . . . . . . 29 3.3 Conditionals: ifandswitch . . . . . . . . . . . . . . . . 31 3.4 Loops: forandwhile. . . . . . . . . . . . . . . . . . . . 32 3.5 Debuggingandprofiling . . . . . . . . . . . . . . . . . . . . 33 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 4 MoreonFunctions 37 4.1 Functionhandlesandanonymousfunctions . . . . . . . . . . 37 4.2 Subfunctionsandnestedfunctions . . . . . . . . . . . . . . 39 vii (cid:1) (cid:1) (cid:1) (cid:1) “matlabbook” (cid:1) (cid:1) 2009/5/27 pageviii (cid:1) (cid:1) viii Contents 4.3 Errorsandwarnings . . . . . . . . . . . . . . . . . . . . . . 41 4.4 Inputandoutputarguments,revisited . . . . . . . . . . . . . 41 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5 Graphics 45 5.1 Dataplotsversusfunctionplots . . . . . . . . . . . . . . . . 45 5.1.1 ezplots . . . . . . . . . . . . . . . . . . . . . . . 46 5.1.2 Two-dimensionaldataplots . . . . . . . . . . . . . 48 5.1.3 Three-dimensionaldataplots . . . . . . . . . . . . 49 5.2 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5.3 Handlesandproperties . . . . . . . . . . . . . . . . . . . . 51 5.4 Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 5.5 Savingandexportingfigures . . . . . . . . . . . . . . . . . 53 5.6 Othercommongraphicstechniques . . . . . . . . . . . . . . 55 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 6 AdvancedTechniques 59 6.1 Memorypreallocation . . . . . . . . . . . . . . . . . . . . . 59 6.2 Vectorization . . . . . . . . . . . . . . . . . . . . . . . . . . 60 6.3 Masking . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.4 Scopingexceptions . . . . . . . . . . . . . . . . . . . . . . 64 6.5 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 6.6 Cellarrays . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 6.7 Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 7 ScientificComputing 75 7.1 Linearalgebra . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.2 Iterativelinearalgebra . . . . . . . . . . . . . . . . . . . . . 78 7.3 Rootfinding . . . . . . . . . . . . . . . . . . . . . . . . . . 79 7.4 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . 80 7.5 Datafittingandinterpolation . . . . . . . . . . . . . . . . . 81 7.6 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 7.7 Initial-valueproblems . . . . . . . . . . . . . . . . . . . . . 85 7.8 Boundary-valueproblems . . . . . . . . . . . . . . . . . . . 86 7.9 Time-dependentpartialdifferentialequations . . . . . . . . . 88 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Afterword 93 Index 95 (cid:1) (cid:1) (cid:1) (cid:1) “matlabbook” (cid:1) (cid:1) 2009/5/27 pageix (cid:1) (cid:1) List of Figures 1.1 InitialMATLABdesktopwindow.(Microsoft®Windows® XP versionshown.) . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3.1 DebuggingtoolsintheMATLABEditor. . . . . . . . . . . . . 33 5.1 Apartialgraphicsobjecthierarchy. Exceptforthegroup/series case,eachnameisagraphicsobjecttypeaswellasalow-level commandname. . . . . . . . . . . . . . . . . . . . . . . . . . 46 5.2 Resultofanezplotcommand.. . . . . . . . . . . . . . . . . 47 5.3 SemilogplotofU.S.censusdata,andanextrapolation. . . . . . 49 7.1 Exampleofaleast-squaresfittodata. . . . . . . . . . . . . . . 82 7.2 One-dimensionalinterpolation. . . . . . . . . . . . . . . . . . 83 7.3 SolutionoftheAllen–Cahnequationbybvp4c. . . . . . . . . 88 7.4 MethodoflinesresultforaPDEinonedimension. . . . . . . . 89 ix (cid:1) (cid:1) (cid:1) (cid:1) “matlabbook” (cid:1) (cid:1) 2009/5/27 pagex (cid:1) (cid:1) (cid:1) (cid:1) (cid:1) (cid:1)

Description:
This engaging book is a very compact introduction to the essentials of the MATLAB programming language and is ideal for readers seeking a focused and brief approach to the software. Learning MATLAB contains numerous examples and exercises involving the software s most useful and sophisticated featur
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.