This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: MATLAB Tutorial Steven Levandosky Department of Mathematics Stanford University Copyright 2001 1 Contents 1 Introduction 3 2 Getting Started 3 3 Variables 4 4 Matrices and Vectors 6 5 Dot Products and Cross Products 9 6 Basic Matrix Operations 11 7 Reduced Row Echelon Form 14 8 Rank 18 9 Inverses 20 10 Eigenvectors and Eigenvalues 23 11 Componentwise Operations 24 12 Plotting Curves 25 13 Plotting Surfaces 28 14 Level Curves 32 15 Vector Fields 34 16 Symbolic Variables and Expressions 36 17 Solving Algebraic Equations 39 18 Derivatives 40 19 MFiles 45 2 1 Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science and engineering, as well as in mathematics. This tutorial is designed to provide the reader with a basic understanding of how MATLAB works, and how to use it to solve problems in linear algebra and multivariable calculus. It is intended to complement the regular course materials. So, although we often recall many of the basic definitions and results, we assume the reader already has some familiarity with them. All of the commands in this document were executed using version 5.3, and should also work in version 6. 2 Getting Started When MATLAB starts (either by typing matlab at the command prompt on a Unix machine, or running the executable on a PC or Mac) the MATLAB prompt >> appears. All MATLAB commands are executed from this prompt. >> 2.3+4.2 ans = 6.5000 By default MATLAB returns numerical expressions as decimals with 5 digits. The format function is used to change the format of the output. Type format rat to have MATLAB return rational expressions. >> format rat >> 5.13.3 ans = 9/5 To eliminate the extra spacing type format compact . >> format compact >> 5*7 ans = 35 3 The four basic operations of addition, subtraction, multiplication and division are performed using the symbols +,,* and / , respectively. Exponentiation is performed by means of the symbol ^ . >> 2^7 ans = 128 MATLAB has most standard mathematical functions builtin. The sqrt function computes the square root. >> format long >> sqrt(2) ans = 1.41421356237310 The basic trigonometric functions ( cos , sin , tan , sec , csc , cot ), their inverses ( acos , asin , atan , asec , acsc , acot ), the exponential function exp , and the natural logarithm log are also builtin. For instance, ln(4) + cos( π/ 6) is computed as follows. >> log(4)+cos(pi/6) ans = 2.25231976490433 For information about any MATLAB function, type help followed by the name of the func tion. >> help abs ABS Absolute value. ABS(X) is the absolute value of the elements of X. When X is complex, ABS(X) is the complex modulus (magnitude) of the elements of X....
View
Full
Document
This note was uploaded on 06/16/2010 for the course MS&E 201 taught by Professor Edisontse during the Spring '08 term at Stanford.
 Spring '08
 EdisonTse

Click to edit the document details