No BSD License  

Highlights from
Row Echelon Form

2.5

2.5 | 2 ratings Rate this file 14 Downloads (last 30 days) File Size: 1011 Bytes File ID: #18755
image thumbnail

Row Echelon Form

by

 

14 Feb 2008 (Updated )

Method for row echelon form of matrix

| Watch this File

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)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
21 Sep 2009 Evans Doe Ocansey

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

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  

Contact us