Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Math Topics » alt.algebra.help.independent

Topic: Inversion
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Gokhan Ors

Posts: 2
Registered: 5/19/10
Inversion
Posted: May 19, 2010 9:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi everyone
i need help to understand how these codes making inverse on MatLab.It's using Gauss Jordan methode but i couldnt get how it does.I'll be grateful if you could show me on 2*2 Matrix.
Thanks
Here the link
http://www.matrixlab-examples.com/matrix-inversion.html

and codes


function b = mat_inv2(a)
% Find dimensions of input matrix
[r,c] = size(a);

% If input matrix is not square, stop function
if r ~= c
disp('Only Square Matrices, please')
b = [];
return
end

% Target identity matrix to be transformed into the output
% inverse matrix
b = eye(r);

%The following code actually performs the matrix inversion
for j = 1 : r
for i = j : r
if a(i,j) ~= 0
for k = 1 : r
s = a(j,k); a(j,k) = a(i,k); a(i,k) = s;
s = b(j,k); b(j,k) = b(i,k); b(i,k) = s;
end
t = 1/a(j,j);
for k = 1 : r
a(j,k) = t * a(j,k);
b(j,k) = t * b(j,k);
end
for L = 1 : r
if L ~= j
t = -a(L,j);
for k = 1 : r
a(L,k) = a(L,k) + t * a(j,k);
b(L,k) = b(L,k) + t * b(j,k);
end
end
end
end
break
end
% Display warning if a row full of zeros is found
if a(i,j) == 0
disp('Warning: Singular Matrix')
b = 'error';
return
end
end
% Show the evolution of the input matrix, so that we can
% confirm that it became an identity matrix.
a



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.