### Highlights from Row Echelon Form

2.0
2.0 | 3 ratings Rate this file 11 Downloads (last 30 days) File Size: 1011 Bytes File ID: #18755 Version: 1.0

# Row Echelon Form

### Muhammad Rafiullah Arain (view profile)

14 Feb 2008 (Updated )

Method for row echelon form of matrix

File Information
Description

The ref() returns row-echelon-form of nxn matrix.

Example
>> a=[1 2 3 5; 2 4 5 6; 7 3 7 2; 2 4 1 8]
>> ref(a)
result show a row-echelon-form

MATLAB release MATLAB 7 (R14)
15 Mar 2015 Everett Malone

### Everett Malone (view profile)

21 Sep 2009 Evans Doe Ocansey

### Evans Doe Ocansey (view profile)

I tried your code for this matrix
A = [2 3 4 5;6 7 8 9;10 11 12 13; 14 15 16 17];
and the result it's giving me is

1.0000 1.5000 2.0000 2.5000
0 1.0000 2.0000 3.0000
NaN NaN NaN NaN
NaN NaN NaN NaN

But when I tried it manually I mean with my hands I got zeros replacing of all the places with NaN. Kindly help.
Thanks

Comment only
05 May 2008 Tim Davis

Warning ... this function does not pivot, which makes it useless for the general case.

The result R=ref(A) can be computed much more simply with [L,U]=lu(A) ; R = diag(diag(U))\U ; so this does not extend MATLAB in any useful way.

So perhaps the code is here just for educational use. However, codes like that must be well commented and well-written; this one is neither. It contains an absurd test (if (i == j)) which by inspection is always true. It contains gems of true absurdity such as statemients like a(i,:)= (1/a(i,j))* a(i,:); Why are you multiplying by the inverse of scalar? That is slow and inaccurate and hard to read. It uses n=length(a(1,:)) simply to determine the dimension of the input matrix a. Finally, the code is pure scalar code with lots of explicit loops.

26 Apr 2008 Henry Andrew