ebook img

Basics of MATLAB and Beyond - Andrew Knight PDF

205 Pages·2006·3.37 MB·English
by  
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 Basics of MATLAB and Beyond - Andrew Knight

B A S I C S O F M ATLAB® and Beyond (cid:1)c 2000byCRCPressLLC B A S I C S O F M ® ATL AB and Beyond Andrew Knight CHAPMAN & HALL/CRC Boca Raton London New York Washington, D.C. Library of Congress Cataloging-in-Publication Data Knight, Andrew (Andrew James), 1961— Basics of MATLAB and beyond / Andrew Knight. p. cm. Includes index. (alk. paper) ISBNO-8493-2039-9 1. Engitteering mathematics-Data prccessing. 2. MATLAB. I. Title. TA345.K63 1999 620´.001´5 118-dc2 1 99-31210 CIP J This book contains information obtained from authentic and highly regarded sources. Reprinted material is quoted with permission, and sources are indicated. A wide variety of references are listed. Reasonable efforts have hen made to publish reliable data and information, but the author and the publisher cannot assume responsibility for the validity of all materials or for the consequences of their use. Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, microtihning, and recording, or by any information storage or retrieval system, without prior permission in writing from the publisher. The consent of CRC Press LLC does not extend to copying for general distribution, for promotion, for creating new works, or for resale. Specific permission must be obtained in writing from CRC Press LLC for such copying. Direct all inquiries to CRC Press LLC, 2000 N.W. Corporate Blvd., Boca Raton, Plorida 33431. 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 tbe CRC Press Web site at www.crcpress.com © 2000 by CRC Press LLC No claim to original U.S. Government works International Standard Bcok Number 0-8493-2039-9 Library of Congress Card Number 99-31210 Printed in the United States of America 3 4 5 6 1 8 9 0 Printed on acid-free paper MATLAB is a registered trademark of The MathWorks, Inc. Preface This book arose from notes written for matlab(cid:1)R training courses run within the Australian Defence Science and Technology Organisation. The book is in two parts. Each part was originally a two-day course, designedassumingthatstudentswereseatedatacomputerwithmatlab running. Part1isanintroductorycoursesuitableforthosewithnoexperience at all with matlab. It is written in a self contained way; if you go through the notes, all the new commands and ideas are explained as they are introduced. Part 2 is a more advanced course suitable for those who are already familiar with the basics of matlab. It covers a variety of topics, some of which you may not be interested in; if so, you should be able to skip that section without detriment to other sections. You can get the m-files that accompany this book from the “Down- load” section of the CRC Press web site (www.crcpress.com). The files are available in zip or gzipped tar format, and can be extracted using WinZip on a PC, or by using gunzip and tar on unix. You will need to put them in a directory where matlab will be able to find them. You can either use the cd command to move matlab’s working directory to the directory you extract the files to, or add that directory to matlab’s search path. (You can display matlab’s current working directory by matlab is a registered trademark of The MathWorks, Inc. For product information, please contact: The MathWorks, Inc. 24 Prime Park Way Natick, MA 01760-1500 USA Tel: 508-647-7000 Fax: 508-647-7107 E-mail: [email protected] Web: www.mathworks.com (cid:1)c 2000byCRCPressLLC typing pwd (print working directory) in the command window.) On a PC or Macintosh, you can add directories to matlab’s path by clicking onthepathbrowserbuttonatthetopofthematlabcommandwindow (it is the button with two folders on it to the left of the question mark button). In the path browser, select the menu “Path→Add to path”, then select the directory containing the extracted files using the browse button (on PCs it is the one with three dots on it), then check the “add to back” option before pressing “OK”. Then click “File→Save Path” before you exit the path browser. If you are using another platform you can use the path command from within matlab (type help path for instructions). You can install this path each time you start matlab by putting an appropriate path command in a file called startup.m in a directorycalledmatlabsituatedimmediatelybelowyourhomedirectory. Many of the graphical examples in this book assume that the figure windowisempty. Toensureanemptyfigurewindowissuethecommand: clf which stands for “clear figure”. If you find that the figure window is obscured by your command window, try shrinking both windows. Or you can type: shg (show graphic) to bring the graphics window to the front. The compan- ion software implements an even shorter abbreviation; type s to bring the graphics window to the front If, on a PC or Macintosh, the figure window is at the front of the screen, or if it has the current focus, just start typing and matlab will switch to the command window and accept your typing. Words appearing in this book in typewriter font, for example, type, represent matlab commands that you can type in, or output produced by matlab. Andrew Knight (cid:1)c 2000byCRCPressLLC About the Author The author completed a Ph.D. in plasma physics at the Flinders Uni- versity of South Australia in the days before matlab. Consequently, he knows how much time can be saved when you don’t have to write your own matrix inversion or polynomial evaluation routines in fortran. His first exposure to matlab was at the Centre for Plasma Physics Research at the Swiss Federal Institute of Technology (Ecole Poly- technique F´ed´erale) in Lausanne, Switzerland, where he continued his researchinplasmaphysics. OnhisreturntoAustraliatotakeupaposi- tion with the Maritime Operations Division of the Defence Science and Technology Organisation, he was given responsibility for research in the flow noise problem of towed sonar arrays. His current research interests include sonar signal processing and information displays. He has been largely responsible for the growth in the use of matlab in his division, and has conducted training courses in matlab. (cid:1)c 2000byCRCPressLLC Contents I Basics of MATLAB 1 First Steps in MATLAB 1.1 Starting MATLAB 1.2 First Steps 1.3 Matrices 1.4 Variables 1.5 The Colon Operator 1.6 Linspace 1.7 Plotting Vectors 2 Typing into MATLAB 2.1 Command Line Editing 2.2 Smart Recall 2.3 Long Lines 2.4 Copying and Pasting 3 Matrices 3.1 Typing Matrices 3.2 Concatenating Matrices 3.3 Useful Matrix Generators 3.4 Subscripting 3.5 End as a subscript 3.6 Deleting Rows or Columns 3.7 Matrix Arithmetic 3.8 Transpose 4 Basic Graphics 4.1 Plotting Many Lines 4.2 Adding Plots 4.3 Plotting Matrices 4.4 Clearing the Figure Window 4.5 Subplots (cid:1)c 2000byCRCPressLLC 4.6 Three-Dimensional Plots 4.7 Axes 4.8 Labels 5 More Matrix Algebra 6 Basic Data Analysis 7 Graphics of Functions of Two Variables 7.1 Basic Plots 7.2 Colour Maps 7.3 Colour Bar 7.4 Good and Bad Colour Maps 7.5 Extracting Logical Domains 7.6 Nonrectangular Surface Domains 8 M-Files 8.1 Scripts 8.2 Functions 8.3 Flow Control 8.4 Comparing Strings 9 Data Files 9.1 MATLAB Format 9.2 ASCII Format 9.3 Other Formats 10 Directories 11 Startup 12 Using MATLAB on Different Platforms 13 Log Scales 14 Curve Fitting—Matrix Division 15 Missing Data 16 Polar Plots 17 Fourier Transform 18 Power Spectrum 19 Sounds in MATLAB (cid:1)c 2000byCRCPressLLC 20 Time-Frequency Analysis 21 Line Animation 22 SPTool 23 Handle Graphics 23.1 Custom Plotting Functions 23.2 Set and Get 23.3 Graphical Object Hierarchy 24 Demos II Beyond the Basics 25 Sparse Arrays 25.1 Example: Airfoil 25.2 Example: Communication Network 26 Text Strings 26.1 String Matrices 26.2 Comparing Strings 26.3 String Manipulations 26.4 Converting Numbers to Strings 26.5 Using Strings as Commands 27 Cell Arrays 28 Structures 28.1 Example: Meteorological Database 28.2 Example: Capturing the List of Variables 29 Multidimensional Arrays 29.1 Generating Multidimensional Grids 29.2 Operations with Multidimensional Arrays 29.3 RGB Images 29.4 Example: Sonar 29.5 Multidimensional Cell Arrays 29.6 Multidimensional Structures 30 Saving and Loading Data 30.1 MATLAB Format 30.2 Other Formats (cid:1)c 2000byCRCPressLLC

Description:
MATLAB. I. Title. TA345.K63. 1999. 620´.001´5 118-dc2 1. 99-31210. CIP. J. This book contains information obtained from authentic and highly .. program above. 2 Typing into MATLAB. 2.1 Command Line Editing. If you make a mistake when entering a matlab command, you do not have to type the
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.