matlab tutorial

# matlab tutorial - MATLAB Tutorial Steven Levandosky...

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

MATLAB Tutorial Steven Levandosky Department of Mathematics Stanford University Copyright 2001 1

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

View Full Document
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 M-Files 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.1-3.3 ans = 9/5 To eliminate the extra spacing type format compact . >> format compact >> 5*7 ans = 35 3

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

View Full Document
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 built-in. 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 built-in. 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. See also SIGN, ANGLE, UNWRAP. Overloaded methods help sym/abs.m To avoid having to retype long expressions use the up arrow key to scroll through lines previously typed. Typing one or more characters and then the up arrow key displays previous lines that begin with those characters. To exit MATLAB type quit .
This is the end of the preview. Sign up to access the rest of the document.

{[ 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