Code covered by the BSD License  

Highlights from
invjor

3.125

3.1 | 8 ratings Rate this file 2 Downloads (last 30 days) File Size: 1.34 KB File ID: #4202

invjor

by Jordi Soler Penades

 

28 Nov 2003 (Updated 04 Mar 2005)

Calculates the inverse of a matrix using Jordan-Gauss method.

| Watch this File

File Information
Description

Calculates the inverse I of a matrix A.

MATLAB release MATLAB 5.3 (R11)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
03 Jun 2004 naveed rao

It would have better , to place the comments in english

02 Mar 2005 Regis Chee

Neat and simple! But I'll also prefer to have English comments.

13 May 2005 lilith suhr

That was exactly what I was looking for.
thx

05 Dec 2005 Duane Hanselman

Poor duplication of MATLAB function inv(A).

21 Nov 2006 knobski bolokov

Excellent needed this to put in my report....weeeeiiiiiiiiiiiii

25 Feb 2009 Semih dalgin

Thnks i tried for 50*50 matrix and gives not very good bad good enough

26 Feb 2009 John D'Errico

Poor. Sorry, but you should NOT be using this code to find an inverse. If anybody is doing so, they are mistaken.

The fact is, you should almost never be computing the inverse in the first place. The very few times this would be of any value, why not use inv anyway? That would be FAR faster. More stable will be to use pinv, which will not give you trash for nearly singular matrices. Even for a 50x50 system, pinv is just as fast.

In almost all circumstances, use backslash to solve systems of equations. Thus if you wish to solve the system

  A*x = b

Use

  x = A\b

or

  x = pinv(A)*b

Do NOT use invjor here.

There is not much help in this, nor . There are no indications that singularity has been detected. No errors, no warnings are issued. As an example, try this utterly simple problem to solve:

A = [0 1;1 0]
A =
     0 1
     1 0

[U,I] = invjor(A)
Ecuations swapping needed
Ecuations swapping needed
U =
     0 1
     1 0
I =
   Inf NaN
   NaN Inf

Gosh, I could swear the inverse is incorrect here. In fact, A is perfectly well conditioned, and the inverse of A is itself!

A*A
ans =
     1 0
     0 1
 
The author gets the size of the matrix, then proceeds to try to "invert" even a non-square matrix.

A = rand(2,3)
A =
      0.81472 0.12699 0.63236
      0.90579 0.91338 0.09754
>> [U,I] = invjor(A)
??? Attempted to access d(3); index out of bounds because numel(d)=2.

Error in ==> invjor at 43
   if d(j)==1;

>> A = rand(3,2)
A =
       0.2785 0.96489
      0.54688 0.15761
      0.95751 0.97059
>> [U,I] = invjor(A)
??? Attempted to access U(1,3); index out of bounds because size(U)=[3,2].

Error in ==> invjor at 33
         Z(k,i)=U(k,i)/U(i,i); % Multiplier

Sorry, but this is no more than a homework assignment, and not a terribly well done one either. I'd give it a C minus at very best. On the file exchange, it is just an F.

22 May 2009 Marco Norambuena  
Please login to add a comment or rating.
Updates
04 Mar 2005

Change of coments language from spanish to english

Tag Activity for this File
Tag Applied By Date/Time
linear algebra Jordi Soler Penades 22 Oct 2008 07:10:03
matrix Jordi Soler Penades 22 Oct 2008 07:10:03
inverse Jordi Soler Penades 22 Oct 2008 07:10:03
jordan Jordi Soler Penades 22 Oct 2008 07:10:03
mathematics Jordi Soler Penades 22 Oct 2008 07:10:03

Contact us at files@mathworks.com