Sie sind auf Seite 1von 1

clear all;

clc;
n= input('Enter the order of matrix : ');
for a=1:n
for b=1:n
yo(a,b)=input('Enter the elements of the matrix');
end
end
a=inv(yo);
disp('Actual Inverse');
disp(a);
for k=1:n
t=yo(k,k);
yn(k,k)=-1/yo(k,k);
for i=1:n
for j=1:n
if(i==k&&j~=k || i~=k&&j==k)
yn(i,j)=yo(i,j)/t;
elseif(i~=k&&j~=k)
yn(i,j)=yo(i,j) - ( (yo(i,k)*yo(k,j)) /t );
end
end
end
yo=yn;
end
x=-yo;
disp('Inverse By Pivotal Method');
disp(x);

Enter the order of matrix : 3


Enter the elements of the matrix2
Enter the elements of the matrix1
Enter the elements of the matrix1
Enter the elements of the matrix1
Enter the elements of the matrix2
Enter the elements of the matrix1
Enter the elements of the matrix1
Enter the elements of the matrix1
Enter the elements of the matrix2
Actual Inverse
0.7500 -0.2500 -0.2500
-0.2500
0.7500 -0.2500
-0.2500 -0.2500
0.7500
Inverse By Pivotal Method
0.7500 -0.2500 -0.2500
-0.2500
0.7500 -0.2500
-0.2500 -0.2500
0.7500

Das könnte Ihnen auch gefallen