ECON
MatlabNotes

MatlabNotes - An Introduction to Matlab Version 2.3 David F...

• Notes
• 37

This preview shows pages 1–4. Sign up to view the full content.

An Introduction to Matlab Version 2.3 David F. Griffiths 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. Griffiths. 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 specified.

This preview has intentionally blurred sections. Sign up to view the full version.

Contents 1 MATLAB 2 2 Starting Up 2 2.1 Windows Systems . . . . . . . . . . 2 2.2 Unix Systems . . . . . . . . . . . . . 2 2.3 Command Line Help . . . . . . . . . 2 2.4 Demos . . . . . . . . . . . . . . . . . 3 3 Matlab as a Calculator 3 4 Numbers & Formats 3 5 Variables 3 5.1 Variable Names . . . . . . . . . . . . 3 6 Suppressing output 4 7 Built–In Functions 4 7.1 Trigonometric Functions . . . . . . . 4 7.2 Other Elementary Functions . . . . . 4 8 Vectors 4 8.1 The Colon Notation . . . . . . . . . 5 8.2 Extracting Bits of a Vector . . . . . 5 8.3 Column Vectors . . . . . . . . . . . . 5 8.4 Transposing . . . . . . . . . . . . . . 5 9 Keeping a record 6 10 Plotting Elementary Functions 6 10.1 Plotting—Titles & Labels . . . . . . 7 10.2 Grids . . . . . . . . . . . . . . . . . . 7 10.3 Line Styles & Colours . . . . . . . . 7 10.4 Multi–plots . . . . . . . . . . . . . . 7 10.5 Hold . . . . . . . . . . . . . . . . . . 7 10.6 Hard Copy . . . . . . . . . . . . . . 8 10.7 Subplot . . . . . . . . . . . . . . . . 8 10.8 Zooming . . . . . . . . . . . . . . . . 8 10.9 Formatted text on Plots . . . . . . . 8 10.10Controlling Axes . . . . . . . . . . . 9 11 Keyboard Accelerators 9 12 Copying to and from Word and other applications 10 12.1 Window Systems . . . . . . . . . . . 10 12.2 Unix Systems . . . . . . . . . . . . . 10 13 Script Files 10 14 Products, Division & Powers of Vec- tors 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 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 equa- tions . . . . . . . . . . . . . . . . . . 18 18 Characters, Strings and Text 20 19 Loops 20 20 Logicals 21 20.1 While Loops . . . . . . . . . . . . . . 22 20.2 if...then...else...end . . . . . . 23 21 Function m–files 23 21.1 Examples of functions . . . . . . . . 24 22 Further Built–in Functions 25 22.1 Rounding Numbers . . . . . . . . . . 25 22.2 The sum Function . . . . . . . . . . . 25 22.3 max & min . . . . . . . . . . . . . . . 26 22.4 Random Numbers . . . . . . . . . . 26 22.5 find for vectors . . . . . . . . . . . . 27 22.6 find for matrices . . . . . . . . . . . 27 23 Plotting Surfaces 27 24 Timing 28 25 On–line Documentation 29 26 Reading and Writing Data Files 29 26.1 Formatted Files . . . . . . . . . . . . 30 26.2 Unformatted Files . . . . . . . . . . 30 27 Graphic User Interfaces 31 28 Command Summary 32 1
1 MATLAB Matlab is an interactive system for doing nu- merical computations. A numerical analyst called Cleve Moler wrote the first version of Matlab in the 1970s. It has since evolved into a successful commercial software package. Matlab relieves you of a lot of the mundane tasks associated with solving problems nu- merically. This allows you to spend more time thinking, and encourages you to experiment. Matlab makes use of highly respected algo- rithms and hence you can be confident about your results.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Fall '10
• DaleJ.POIRIER

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern