Introduction to Matlab

Similar documents
Note: The command name is upper case in the description given by help, but must be lower case in actual use. And the backslash Anb is dierent when A i

The Singular Value Decomposition

The following steps will help you to record your work and save and submit it successfully.

Linear Algebra and Matrices

0.1 Eigenvalues and Eigenvectors

Math 414 Lecture 1. Reading assignment: Text: Pages 1-29 and Scilab Users Guide: Sections 1-3.

In this LAB you will explore the following topics using MATLAB. Investigate properties of the column space of a matrix.

1 Last time: determinants

MAT 343 Laboratory 3 The LU factorization

Conceptual Questions for Review

MATH 2331 Linear Algebra. Section 2.1 Matrix Operations. Definition: A : m n, B : n p. Example: Compute AB, if possible.

Math 102, Winter Final Exam Review. Chapter 1. Matrices and Gaussian Elimination

Eigenvalues, Eigenvectors. Eigenvalues and eigenvector will be fundamentally related to the nature of the solutions of state space systems.

Lecture Notes in Linear Algebra

14 Singular Value Decomposition

Linear Algebra in LabVIEW

MAT 343 Laboratory 6 The SVD decomposition and Image Compression

Matrices and Linear Algebra

AMS10 HW7 Solutions. All credit is given for effort. (-5 pts for any missing sections) Problem 1 (20 pts) Consider the following matrix 2 A =

Cheat Sheet for MATH461

Linear Algebra Highlights

MATH.2720 Introduction to Programming with MATLAB Vector and Matrix Algebra

ELE/MCE 503 Linear Algebra Facts Fall 2018

Introduction to SVD and Applications

TOPIC 2 Computer application for manipulating matrix using MATLAB

6 EIGENVALUES AND EIGENVECTORS

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

LINEAR ALGEBRA REVIEW

MATH 240 Spring, Chapter 1: Linear Equations and Matrices

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB

A Review of Linear Algebra

Maths for Signals and Systems Linear Algebra in Engineering

The Singular Value Decomposition (SVD) and Principal Component Analysis (PCA)

EK102 Linear Algebra PRACTICE PROBLEMS for Final Exam Spring 2016

Linear Algebra, part 3. Going back to least squares. Mathematical Models, Analysis and Simulation = 0. a T 1 e. a T n e. Anna-Karin Tornberg

Chapter 3. Determinants and Eigenvalues

Computational math: Assignment 1

Linear Algebra, part 3 QR and SVD

Linear Algebra Review. Fei-Fei Li

Linear Algebra Review. Vectors

Math Assignment 3 - Linear Algebra

Math 315: Linear Algebra Solutions to Assignment 7

1 Last time: least-squares problems

Example Linear Algebra Competency Test

Review of Linear Algebra

3. Array and Matrix Operations

Math 22AL Lab #4. 1 Objectives. 2 Header. 0.1 Notes

TI89 Titanium Exercises - Part 10.

c c c c c c c c c c a 3x3 matrix C= has a determinant determined by

Linear Least Squares. Using SVD Decomposition.

Computational Foundations of Cognitive Science

ANSWERS. E k E 2 E 1 A = B

Review problems for MA 54, Fall 2004.

1 Linearity and Linear Systems

HOSTOS COMMUNITY COLLEGE DEPARTMENT OF MATHEMATICS

FF505 Computational Science. Matrix Calculus. Marco Chiarandini

USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS

MATH 20F: LINEAR ALGEBRA LECTURE B00 (T. KEMP)

Lecture Summaries for Linear Algebra M51A

15 Singular Value Decomposition

Math 18, Linear Algebra, Lecture C00, Spring 2017 Review and Practice Problems for Final Exam

Reduction to the associated homogeneous system via a particular solution

Math Linear Algebra Final Exam Review Sheet

Numerical Linear Algebra Homework Assignment - Week 2

Linear Algebra Practice Problems

The Singular Value Decomposition

1. General Vector Spaces

Matrix Algebra for Engineers Jeffrey R. Chasnov

2. Every linear system with the same number of equations as unknowns has a unique solution.

(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB

Glossary of Linear Algebra Terms. Prepared by Vince Zaccone For Campus Learning Assistance Services at UCSB

I. Multiple Choice Questions (Answer any eight)

Linear Algebra Section 2.6 : LU Decomposition Section 2.7 : Permutations and transposes Wednesday, February 13th Math 301 Week #4

Matrix Algebra. Matrix Algebra. Chapter 8 - S&B

Homework 1 Elena Davidson (B) (C) (D) (E) (F) (G) (H) (I)

CSL361 Problem set 4: Basic linear algebra

+ MATRIX VARIABLES AND TWO DIMENSIONAL ARRAYS

spring, math 204 (mitchell) list of theorems 1 Linear Systems Linear Transformations Matrix Algebra

L3: Review of linear algebra and MATLAB

Topic 15 Notes Jeremy Orloff

Linear Algebra Review. Fei-Fei Li

Quiz ) Locate your 1 st order neighbors. 1) Simplify. Name Hometown. Name Hometown. Name Hometown.

MATH36001 Generalized Inverses and the SVD 2015

Foundations of Matrix Analysis

Chapter 2: Matrix Algebra

Algebra C Numerical Linear Algebra Sample Exam Problems

Math 4A Notes. Written by Victoria Kala Last updated June 11, 2017

and let s calculate the image of some vectors under the transformation T.

Fall 2016 MATH*1160 Final Exam

ft-uiowa-math2550 Assignment OptionalFinalExamReviewMultChoiceMEDIUMlengthForm due 12/31/2014 at 10:36pm CST

Octave. Tutorial. Daniel Lamprecht. March 26, Graz University of Technology. Slides based on previous work by Ingo Holzmann

LAB 2: Orthogonal Projections, the Four Fundamental Subspaces, QR Factorization, and Inconsistent Linear Systems

Linear Algebra Primer

MATH 350: Introduction to Computational Mathematics

Contents Software Systems for Linear Algebra Problems 531

Singular value decomposition

SUMMARY OF MATH 1600

Numerical Linear Algebra

18.06 Problem Set 3 - Solutions Due Wednesday, 26 September 2007 at 4 pm in

Math 407: Linear Optimization

Transcription:

History of Matlab Starting Matlab Matrix operation Introduction to Matlab Useful commands in linear algebra Scripts-M file Use Matlab to explore the notion of span and the geometry of eigenvalues and eigenvectors. History of Matlab MATLAB stands for MATrix LABoratory. Cleve Moler is a mathematician and computer programmer. In the mid to late 1970s, he invented MATLAB, a numerical computing package, to give his students at the University of New Mexico easy access to Fortran libraries for numerical computing without writing Fortran. In 1984, he co-founded The MathWorks with Jack Little to commercialize this program. MATLAB provides a high-performance technical computing environment. MATLAB combines comprehensive math and graphics functions with a powerful high-level language. Starting MATLAB Press Ctrl-Alt-Delete to begin Login on to UTAD with your UTAD Username and Passwordd Click start Programs MATLAB R2008A MATLAB R2008 A Now you should have MATLAB running on your desktop now. 1

Set up your working directory It s important to set up the right working directory so you can save your works properly. First, Change your working directory to your UT H-Drive by the following steps. Look for Current Directory. Click on the sign... (Browse Folder) Move down the cursor to find your UTAD H-Drive (yourutadusername.utoledo.edu...(h:) Now your current are under your UTAD H Drive. Now create a MATLAB directory by (right) clicking your mouse on the blank spot of Current Directory. Then select New Folder. Then change the name to MATLAB. This is where you save your work. You can create other folders later if you want to organize your files. Entering and Displaying a Matrix The MATLAB prompt is To enter a matrix: start with separate elements of the matrix with space use ; (semicolon) to mark end of each row end the matrix with 1 2 3 Example 1. Enter the matrix A = into work space. 4 5 6 Solution: Type the following, followed by Enter (or return key). A = 1 2 3 ; 4 5 6 You should see A = 1 2 3 4 5 6 2

Example 2. Enter the vector u = 1 2 3 and v = space. Type the following, followed by Enter (or return key). 1 2 3 into work u = 1 2 3 You should see u = 1 2 3 Type the following, followed by Enter (or return key). v = 1; 2; 3 You should see v = 1 2 3 Exercise 1. Enter and display the following matrices in MATLAB. 1 2 3 1 2 B = 4 5 6, C = 3 4. 7 8 9 5 6 Matrix Operation MATLAB can be used to perform the matrix algebra. The symbols for standard operations are: Addition: + Substraction: Multiplication: Power: Transpose: Example 2. Compute AB, A T, B 2, AC and D = BC. What happen if you try DC? Matrix Operation Solution: A B 30 36 42 66 81 96 3

A B 2 A C D = B C D = 1 4 2 5 3 6 30 36 42 66 81 96 102 126 150 22 28 49 64 22 28 49 64 76 100 D C??? Error using = mtimes Inner matrix dimensions must agree. Since DC doesn t make sense, You will see the error information. Now the matrices C and D have the same dimension. We can do the following example. Compute C + D and 2C 3D. Solution: C + D 23 30 52 68 81 106 2 C 3 D 4

64 80 141 184 218 288 Don t forget sign when you multiply a number with a matrix. Submatrices, Rows and Columns of a Matrix and other commands A(i, j): returns the ij entry of the matrix A A(i, :): returns the i th row of A A(:, j): returns the j th column of A. A(p : q, r : s): returns the submatrix from row p to row q and column r to column s. (Here p q and r s.) eye(n): returns a n n identity matrix. zeros(m, n): returns a m n zero matrix. rand(m, n): returns a m n random matrix. Linear algebra commands rref(a): returns the row reduced echelon form of A. det(a): returns the determinant of the square matrix A. trace(a): returns the sum of the diagonal elements of the matrix A size(a): returns the size of a matrix. x = linsolve(a, b) solves the linear system Ax = b using LU factorization. rank(a): returns the rank of A orth(a): returns an orthonormal basis for the range (column space) of A. null(a): returns the orthonormal basis for the null space of of A. Z = null(a, r ): returns a rational basis for the null space obtained from the reduced row echelon form. A Z is zero. Linear algebra commands dot(u, v): returns a scalar product of the vectors u and v. u and v must be vectors of the same length. cross(u, v) returns the cross product of the vectors u and v. u and v must be 3 element vectors. svd(a): returns a vector containing the singular values. U, S, V = svd(a): returns a diagonal matrix S, of the same dimension as A and with nonnegative diagonal elements in decreasing order, and unitary matrices U and V so that A = USV T. L, U = lu(a) stores an upper triangular matrix in U and a psychologically lower triangular matrix (i.e. a product of lower triangular and permutation matrices) in L, so that A = LU. A can be rectangular. L, U, P = lu(a) returns unit lower triangular matrix L, upper triangular matrix U, and permutation matrix P so that P A = LU. 5

Linear algebra commands eig(a): returns a vector containing the eigenvalues of a square matrix A V, D= eig(a): returns a diagonal matrix D of eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that AV = V D svd(a): returns a vector containing the singular values. U, S, V = svd(a): returns a diagonal matrix S, of the same dimension as A and with nonnegative diagonal elements in decreasing order, and unitary matrices U and V so that A = USV T. L, U = lu(a) stores an upper triangular matrix in U and a psychologically lower triangular matrix (i.e. a product of lower triangular and permutation matrices) in L, so that A = LU. A can be rectangular. L, U, P = lu(a) returns unit lower triangular matrix L, upper triangular matrix U, and permutation matrix P so that P A = LU. How to get help Type help command if you are interested in the detail of the command. For example, if you type help svd. You will see the detail about the command svd. You can also scroll down the help window and click on Matlab help. Then click on Mathematics. Then click on Matrices and Linear Algebra. Then you can choose the topics that you are interested in. Scripts M-files A script M-file is just a sequence of MATLAB commands stored in a text file that has.m as its extension. You can use the m editor on MATLAB to create a m file or any other text editor (like notepad but not WORD). After creating a m-file, you just need to type the name of the file (without.m) to run the command in the m-file. You can download fern.m, eigshow.m and spanshow.m from http : //math.utoledo.edu/ mtsui/techseminar/f ern.m http : //math.utoledo.edu/ mtsui/techseminar/eigshow.m and http : //math.utoledo.edu/ mtsui/techseminar/span Make sure that you save these files as fern.m, eigshow.m and spanshow.m. Save these three files in your current directory. Now type fern. You should see the fractal fern. Scripts M-files 6

Example. Create a m-file named project1.m that creates a matrix 1 2 1 A = 1 2 2 and compute B = A 3 6A 2 + 5A 3I. 2 1 3 Solution: First Click on file. Then click on New and choose M-file. Type the following: A = 1 2 1 ; 1 2 2 ; 2 1 3 A 3 6 A 2 + 5 A + 3 eye(3) Then save the file as project1.m to your working directory. Note that each command is in different lines. Now type project1. You should see the results. A = B = eigshow 0 0 0 0 0 0 0 0 0 1 2 1 1 2 2 2 1 3 and Example 1. Type eigshow to explore the geometry of the eigenvalues and eigenvectors of a 2 2 matrix. 1 2 Example 2. Let A =. Type eigshow(a) the geometry of the 2 1 eigenvalues and eigenvectors of a 2 2 matrix. spanshow A is a 3 3 matrix. spanshow(a): Show the plane spanned by the first two column vectors and the the line span by the third column vector. 1 2 1 Example 1. Create A = 1 2 2 and type spanshow(a). 2 1 3 1 2 1 Example 2. Create A = 2 1 1 and type spanshow(a). 2 1 1 7