File Exchange

image thumbnail

Row Echelon Form

version 1.0 (1011 Bytes) by

Method for row echelon form of matrix



No License

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

>> 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

Comments and Ratings (4)

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.

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.

Henry Andrew

MATLAB Release
MATLAB 7 (R14)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video