Project 3 - Matrix Inversion Using Cofactors

Write a MATLAB program which does the following:

  1. Accepts a square matrix "A" entered from the keyboard, preferably one row at a time.
  2. Calculates the cofactor matrix, cof(A).
  3. Calculates the adjoint matrix Adj(A).
  4. Finds the inverse matrix from

    if the original matrix is nonsingular.
  5. Accepts a vector b and solves the system of equations Ax = b when a unique solution x exists.

There should be some elementary error checking such as verifying that b has the appropriate dimension. Note, b can be input as either a row or column vector, but it must be a column vector when determining the solution from x = A-1 b.

Run your program and display A, b, cof(A), Adj(A), and when A is nonsingular, A-1 and x for the cases below.