Lab 4
Lab 4
is type2m or to multiply a row by a constant and add it to another row which is type3m.
end
out=eye(n);
out(j,k)=c;
end
If we want to create a general equation that will help us reduce any n x (n+1) matrix to row echelon
form we can take the basic functions and create a general one using loops.
function A=myref(B)
[n,m]=size(B);
for j=1:n
for k=1:n
if j<=k
B=type3m(n,k,j,-B(k,j)/B(j,j))*B;
B=type2m(n,j,1/B(j,j))*B;
end
end
end
A=B;
A=rand(4,5)
A=
>> myref(A)
ans =
0 0 0 1.0000 1.7264
>> A=rand(6,7)
A=
>> myref(A)
ans =
1.0000 0.5240 1.3987 2.2232 2.6843 2.3399 1.8457
0 0 0 0 0 1.0000 0.9059