plugin-math245lab12

# plugin-math245lab12 - Math245 Computer Lab set#12 Spring...

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Math245 Computer Lab set #12, Spring 2009 1 Matrix computation by using Matlab Matlab is an excellent tool for matrix related computations. Here we show a few examples to compute a determinant, an inverse matrix, a solution to a linear system and eigenvalues/eigenvectors. Example Consider a linear system Ax = b with A = 1 0 2 1- 2 3 2 1 and b = 2- 3 12 . Define matrix A and right hand side of equation b A=[1 0 0; 2 1 -2; 3 2 1] A = 1 2 1-2 3 2 1 b =[2 -3 12]’ b = 2-3 12 Compute determinant of A det(A) ans = 5 Compute inverse matrix A- 1 inv(A) ans = 1.0000-1.6000 0.2000 0.4000 0.2000-0.4000 0.2000 Check if this is really an inverse of A (A- 1 A should be an identity I) inv(A)*A ans = 1 1 1 1 Solve a linear system Ax = b A\b ans = 2.0000 1.0000 4.0000 So the solution x = 2 . 1 . 4 . . The backslash symbol ‘ \ ’ is called a left-division operator. Compute eigenvalues of A eig(A) ans = 1.0000 + 2.0000i 1.0000 - 2.0000i 1.0000 Compute eigenvectors and eigenvalues at the same time [vec, val]=eig(A) vec = 0.4851 0.7071 0.7071-0.7276 0 - 0.7071i 0 + 0.7071i 0.4851 val = 1.0000 + 2.0000i 1.0000 - 2.0000i 1.0000 Each eigenvector is stored in each column of matrix...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

plugin-math245lab12 - Math245 Computer Lab set#12 Spring...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online