math245lab11

# math245lab11 - Math245 Computer Lab set#11 Spring 2008...

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

Math245 Computer Lab set #11, Spring 2008 Matrix computation by using Matlab Matlab is a excellent tool for matrix related computations. Here is just a little example to compute the determinant, inverse matrix, solution to the linear system and eigenvalue/eigenvectors. Example Consider a linear system Ax = b with A = 1 0 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 0 0 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 0 0 -1.6000 0.2000 0.4000 0.2000 -0.4000 0.2000 Check if this is really a inverse of A (A - 1 A should be identity I) inv(A)*A ans = 1 0 0 0 1 0 1

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

View Full Document
0 0 1 Solve a linear system Ax = b A\b ans = 2.0000 1.0000 4.0000 So the solution x = 2 . 0 1 . 0 4 . 0 . The backslash symbol ‘ \ ’ is called left division operator. Compute eigenvalue of A eig(A) ans = 1.0000 + 2.0000i 1.0000 - 2.0000i 1.0000 Compute eigenvector and eigenvalue at the same time [vec, val]=eig(A) vec = 0 0 0.4851 0.7071 0.7071 -0.7276 0 - 0.7071i 0 + 0.7071i 0.4851 val = 1.0000 + 2.0000i 0 0 0 1.0000 - 2.0000i 0 0 0 1.0000 Each eigenvector is stored in each column of matrix vec .
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