Question

In: Computer Science

wrote a code in mathlab to find the inverse of a matrix (5x5), USING CoFACTOR method....

wrote a code in mathlab to find the inverse of a matrix (5x5), USING CoFACTOR method. use numbers 1-15 as variables

Solutions

Expert Solution

Answer:-

Formula

We have to write script file to find out cofactor of matrix.

Script file:-

%-----------------------------------------------------------------------------------------------------------------------------

function cof=cof(a)

%% Check Input Argument
%----------------------
if isempty(a)
error(message('cof:EmptyMatrix'));
end
%% Algorithm
%-----------
[r, c] = size(a); %determine size of input   
m = ones(r,c); %preallocate r x c cofactor matrix
a_temp=a; %create temporary matrix equal to input
for i = 1:r
for k = 1:c
a_temp([i],:)=[]; %remove ith row
a_temp(:,[k])=[]; %remove kth row
m(i,k) = ((-1)^(i+k))*det(a_temp); %compute cofactor element
a_temp=a; %reset elements of temporary matrix to input elements
end
end
cof=m; %return cofactor matrix as output variable
end

%----------------------------------------------------------------------------------------------------------------------------

Paste above file in Editor section of matlab

(save it as name 'cof')

Then in command window type these command.(TYPE YOUR MATRIX AND INVERSE FORMULA given below)

Step 1.)  a=[1 2 5 4 8;7 5 8 9 6;4 1 4 5 2;7 8 5 6 3;7 8 5 2 1]

Step 2.) inverse=cof(a)'/det(a)

cof(a) command help us to find out cofactor of 'a' matrix.

det(a) command help us to find out Determent of 'a' matrix

cof(a)' Transpose of cofactor matrix

INVERSE formula using cofactor =  cof(a)'/det(a)

output:-

Editor Section

Command Window section :-

Full-screen shot of a working screen :-

If you need any help in understanding, Please comment your query.

I tried my best for this question, I hope you upvote my answer.

Thank You


Related Solutions

Use this theorem to find the inverse of the given matrix or show that no inverse...
Use this theorem to find the inverse of the given matrix or show that no inverse exists. (If an answer does not exist, enter DNE in any cell.) 1    2    5    1 −1    0    2    1 2    1    −5    0 1    1    2    1
How to write a self-defined function to find the inverse of a matrix by using Gaussian...
How to write a self-defined function to find the inverse of a matrix by using Gaussian Jordan method in MATLAB? Thanks.
Estimate the lowest eigenvalue pair of matrix A using the Inverse Power Method A = 2  8...
Estimate the lowest eigenvalue pair of matrix A using the Inverse Power Method A = 2  8 10 8 4 5 10 5 7 starting with initial guess x0 = [1 1 1]T and εaλ ≤ 1%
Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply...
Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply Normalization: (X - Mean) / Deviation
Use the matrix inverse and the matrix division method to solve the following set for x and y in terms of c:
Use the matrix inverse and the matrix division method to solve the following set for x and y in terms of c:
Find the inverse of the matrix [ 1 1 4 ] [ 3 2 4 ]...
Find the inverse of the matrix [ 1 1 4 ] [ 3 2 4 ] [ 1 1 6 ] It is a 3*3 matrix
Using a system of equations, prove that a 2x2 matrix A has a right inverse if...
Using a system of equations, prove that a 2x2 matrix A has a right inverse if and only if it has a left inverse.
Find the inverse of the matrix A= 2 -1 3 0 1 1 -1 -1 0
Find the inverse of the matrix A= 2 -1 3 0 1 1 -1 -1 0
: Find the inverse of the three matrices listed below. The code should prompt the user...
: Find the inverse of the three matrices listed below. The code should prompt the user to input the size of the matrix and to put the value of each element in the matrix. The output should contain the solution to the inverse from using a function created by you, and the solution found using the NumPy package. I1 = [ 1 2 3 4]−1 I2 = [ 1 2 3 4 5 6 7 2 9 ] −1 I3...
find solutions to the following using Excel's matrix operations?
find solutions to the following using Excel's matrix operations?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT