basis of matlab

11
7/31/2019 basis of MATLAB http://slidepdf.com/reader/full/basis-of-matlab 1/11 BASICS OF and Beyond M ATLAB ® c 2000 by CRC Press LLC

Upload: sakolkong

Post on 05-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 1/11

B AS IC S O F

and BeyondMATLAB

®

c 2000 by CRC Press LLC

Page 2: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 2/11

CHAPMAN & HALL/CRC

An d re w Kn ig h t

B AS I C S O F

and Beyond

MATLAB®

Boca Raton London New York Washington, D.C.

Page 3: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 3/11

Page 4: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 4/11

Preface

This book arose from notes written for matlabR training courses runwithin the Australian Defence Science and Technology Organisation.The book is in two parts. Each part was originally a two-day course,designed assuming that students were seated at a computer with matlab

running.Part 1 is an introductory course suitable for those with no experience

at all with matlab. It is written in a self contained way; if you gothrough the notes, all the new commands and ideas are explained asthey are introduced.

Part 2 is a more advanced course suitable for those who are alreadyfamiliar with the basics of  matlab. It covers a variety of topics, someof which you may not be interested in; if so, you should be able to skipthat 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 filesare available in zip or gzipped tar format, and can be extracted usingWinZip on a PC, or by using gunzip and tar on unix. You will need toput them in a directory where matlab will be able to find them. Youcan either use the cd command to move matlab’s working directory tothe 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-7000Fax: 508-647-7107

E-mail: [email protected]

Web: www.mathworks.com

c 2000 by CRC Press LLC

Page 5: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 5/11

typing pwd (print working directory) in the command window.) On aPC or Macintosh, you can add directories to matlab’s path by clickingon the path browser button at the top of the matlab command window(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 browsebutton (on PCs it is the one with three dots on it), then check the “addto back” option before pressing “OK”. Then click “File→Save Path”before you exit the path browser. If you are using another platform youcan use the path command from within matlab (type help path forinstructions). You can install this path each time you start matlab

by putting an appropriate path command in a file called startup.m in adirectory called matlab situated immediately below your home directory.

Many of the graphical examples in this book assume that the figurewindow is empty. To ensure an empty figure window issue the command:

clf

which stands for “clear figure”. If you find that the figure window isobscured by your command window, try shrinking both windows. Oryou 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 frontIf, 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 willswitch 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 producedby matlab.

Andrew Knight

c 2000 by CRC Press LLC

Page 6: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 6/11

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, heknows how much time can be saved when you don’t have to write yourown matrix inversion or polynomial evaluation routines in fortran.His first exposure to matlab was at the Centre for Plasma PhysicsResearch at the Swiss Federal Institute of Technology (Ecole Poly-technique Federale) in Lausanne, Switzerland, where he continued hisresearch in plasma physics. On his return to Australia to take up a posi-tion with the Maritime Operations Division of the Defence Science andTechnology Organisation, he was given responsibility for research in theflow noise problem of towed sonar arrays. His current research interestsinclude sonar signal processing and information displays. He has beenlargely responsible for the growth in the use of  matlab in his division,and has conducted training courses in matlab.

c 2000 by CRC Press LLC

Page 7: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 7/11

Page 8: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 8/11

4.6 Three-Dimensional Plots4.7 Axes4.8 Labels

5 More Matrix Algebra

6 Basic Data Analysis

7 Graphics of Functions of Two Variables7.1 Basic Plots7.2 Colour Maps7.3 Colour Bar7.4 Good and Bad Colour Maps7.5 Extracting Logical Domains

7.6 Nonrectangular Surface Domains

8 M-Files8.1 Scripts8.2 Functions8.3 Flow Control8.4 Comparing Strings

9 Data Files

9.1 MATLAB Format9.2 ASCII Format9.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

c 2000 by CRC Press LLC

Page 9: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 9/11

20 Time-Frequency Analysis

21 Line Animation

22 SPTool

23 Handle Graphics23.1 Custom Plotting Functions23.2 Set and Get

23.3 Graphical Object Hierarchy

24 Demos

II Beyond the Basics

25 Sparse Arrays25.1 Example: Airfoil25.2 Example: Communication Network

26 Text Strings26.1 String Matrices26.2 Comparing Strings

26.3 String Manipulations26.4 Converting Numbers to Strings26.5 Using Strings as Commands

27 Cell Arrays

28 Structures28.1 Example: Meteorological Database28.2 Example: Capturing the List of Variables

29 Multidimensional Arrays29.1 Generating Multidimensional Grids29.2 Operations with Multidimensional Arrays29.3 RGB Images29.4 Example: Sonar29.5 Multidimensional Cell Arrays29.6 Multidimensional Structures

30 Saving and Loading Data

30.1 MATLAB Format30.2 Other Formats

c 2000 by CRC Press LLC

Page 10: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 10/11

31 Handle Graphics31.1 Get and Set31.2 Default Object Properties31.3 Current Objects

32 Axes Effects32.1 The Axis Command32.2 Tick Marks and Labels32.3 Subplots32.4 Double Axes32.5 Axes Labels

33 Text in Graphics33.1 Symbols and Greek Letters33.2 Symbols in Tick Labels33.3 Global Object Placement

34 Graphical User Interfaces34.1 Callbacks34.2 UIControls34.3 Exclusive Radio Buttons34.4 Variables in GUIs34.5 The Tag Property

34.6 UIMenus34.7 Fast Drawing34.8 Guide34.9 Other Aids

35 Printing Graphics35.1 Print Size: Orient

35.2 Print Size: WYSIWYG35.3 Including Figures in Other Applications

36 Irregular Grids36.1 Interpolation over a Rectangular Grid36.2 Triangular Gridding

37 Three-dimensional Modelling37.1 Patches37.2 Light Objects

38 MATLAB Programming

38.1 Vectorising Code38.2 M-File Subfunctions38.3 Debugging38.4 Profiler

c 2000 by CRC Press LLC

Page 11: basis of MATLAB

7/31/2019 basis of MATLAB

http://slidepdf.com/reader/full/basis-of-matlab 11/11

39 Answers to Exercises (Part I)

40 Answers to Exercises (Part II)