# example - Example Project 1 Dene a Matlab function...

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

Example Project 1. Define a Matlab function X=cramer(A,b) which solves the system A*X=b . You may assume that A is a square ( n × n ) matrix, and that b is a column vector in R n . 2. Use your program to solve the system A*X=b with A=magic(7) and b=[1;2;3;4;5;6;7] . Solution 1. Cramer’s rule is a method for solving a nonsingular n × n system of linear equations Avectorx = vector b . The method is as follows: For j = 1 , 2 ,...,n define an n × n matrix C j by replacing the j th column of A by vector b . Thus if A = [ vectora 1 ,vectora 2 ,...,vectora n ], then C 2 = [ vectora 1 , vector b,vectora 3 ,...,vectora n ]. The value of x j in the (unique) solution to Avectorx = vector b is then the determinant of C j divided by the determinant of A . This algorithm can be implemented as follows. function X=cramer(A,b) % % This function solves the system A*X=b using Cramer’s rule.

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.

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