
A Practical Introduction to Matlab
(Updated for Matlab 5)
Mark S. Gockenbach
Contents
1Introduction 2
2 Simple calculations and graphs 2
2.1 Entering vectors and matrices built-in variables and functions
help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Arithmetic operations on matrices . . . . . . . . . . . . . . . . . 7
2.3.1 Standard operations . . . . . . . . . . . . . . . . . . . . . 7
2.3.2 Solving matrix equations using matrix division . . . . . . 9
2.3.3 Vectorized functions and operators more on graphs . . . 10
2.4 Some miscellaneous commands . . . . . . . . . . . . . . . . . . . 11
3 Programming in Matlab 13
3.1 Conditionals and loops . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Scripts and functions . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 A nontrivial example . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Advanced matrix computations 20
4.1 Eigenvalues and other numerical linear algebra computations . . 20
4.2 Sparse matrix computations . . . . . . . . . . . . . . . . . . . . . 22
4.2.1 Creating a sparse matrix . . . . . . . . . . . . . . . . . . . 22
5 Advanced Graphics 24
5.1 Putting several graphs in one window . . . . . . . . . . . . . . . 24
5.2 3D plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.3 Parametric plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6 Solving nonlinear problems in Matlab 28
7 Eciency in Matlab 29
Department of Mathematical Sciences, Michigan Technological University
1