# Matlab

**Topics:**Matrix, Matrices, Linear algebra

**Pages:**66 (18263 words)

**Published:**July 28, 2010

Version 2.3

David F. Griﬃths

Department of Mathematics The University Dundee DD1 4HN

With additional material by Ulf Carlsson Department of Vehicle Engineering KTH, Stockholm, Sweden

Copyright c 1996 by David F. Griﬃths. Amended October, 1997, August 2001, September 2005. This introduction may be distributed provided that it is not be altered in any way and that its source is properly and completely speciﬁed.

Contents

1 MATLAB 2 Starting Up 2.1 Windows Systems . 2.2 Unix Systems . . . . 2.3 Command Line Help 2.4 Demos . . . . . . . . 3 Matlab as a Calculator 4 Numbers & Formats 5 Variables 5.1 Variable Names . . . . . . . . . . . . 6 Suppressing output 7 Built–In Functions 7.1 Trigonometric Functions . . . . . . . 7.2 Other Elementary Functions . . . . . 8 Vectors 8.1 The Colon Notation . . . . 8.2 Extracting Bits of a Vector 8.3 Column Vectors . . . . . . . 8.4 Transposing . . . . . . . . . 9 Keeping a record 10 Plotting Elementary Functions 10.1 Plotting—Titles & Labels . . 10.2 Grids . . . . . . . . . . . . . . 10.3 Line Styles & Colours . . . . 10.4 Multi–plots . . . . . . . . . . 10.5 Hold . . . . . . . . . . . . . . 10.6 Hard Copy . . . . . . . . . . 10.7 Subplot . . . . . . . . . . . . 10.8 Zooming . . . . . . . . . . . . 10.9 Formatted text on Plots . . . 10.10Controlling Axes . . . . . . . 11 Keyboard Accelerators 2 2 2 2 2 3 3 3 3 3 4

15 Examples in Plotting

13

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

16 Matrices—Two–Dimensional Arrays 13 16.1 Size of a matrix . . . . . . . . . . . . 14 16.2 Transpose of a matrix . . . . . . . . 14 16.3 Special Matrices . . . . . . . . . . . 14 16.4 The Identity Matrix . . . . . . . . . 14 16.5 Diagonal Matrices . . . . . . . . . . 15 16.6 Building Matrices . . . . . . . . . . . 15 16.7 Tabulating Functions . . . . . . . . . 15 16.8 Extracting Bits of Matrices . . . . . 16 16.9 Dot product of matrices (.*) . . . . 16 16.10Matrix–vector products . . . . . . . 16 16.11Matrix–Matrix Products . . . . . . . 17 16.12Sparse Matrices . . . . . . . . . . . . 17 17 Systems of Linear Equations 18 17.1 Overdetermined system of linear equations . . . . . . . . . . . . . . . . . . 18 20

4 4 4 18 Characters, Strings and Text

. . . .

. . . .

. . . .

. . . .

. . . .

20 4 19 Loops 5 20 Logicals 21 5 20.1 While Loops . . . . . . . . . . . . . . 22 5 20.2 if...then...else...end . . . . . . 23 5 6 21 Function m–ﬁles 23 21.1 Examples of functions . . . . . . . . 24 25 25 25 26 26 27 27 27 28 29

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

6 22 Further Built–in Functions 7 22.1 Rounding Numbers . . . . 7 22.2 The sum Function . . . . . 7 22.3 max & min . . . . . . . . . 7 22.4 Random Numbers . . . . 7 22.5 find for vectors . . . . . . 8 22.6 find for matrices . . . . . 8 8 23 Plotting Surfaces 8 9 24 Timing 9 25 On–line Documentation

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

12 Copying to and from Word and other 26 Reading and Writing Data Files 29 applications 10 26.1 Formatted Files . . . . . . . . . . . . 30 12.1 Window Systems . . . . . . . . . . . 10 26.2 Unformatted Files . . . . . . . . . . 30 12.2 Unix Systems . . . . . . . . . . . . . 10 27 Graphic User Interfaces 31 13 Script Files 10 28 Command Summary 32 14 Products, Division & Powers of Vectors 11 14.1 Scalar Product (*) . . . . . . . . . . 11 14.2 Dot Product (.*) . . . . . . . . . . . 11 14.3 Dot Division of Arrays (./) . . . . . 12 14.4 Dot Power of Arrays (.^) . . . . . . 12

1

1

MATLAB

• Matlab is an interactive system for doing numerical computations. • A numerical analyst called Cleve Moler wrote the ﬁrst version of Matlab in the 1970s. It has since evolved into a successful commercial software package.

• from the separate Help window found under the Help menu or • from the Matlab helpdesk stored...

Please join StudyMode to read the full document