I am trying to write my own rref and have the following code. It appears to have worked for the first column but not for all other columns for a test augmented matrix I entered. Can you please assist? Thanks!
9 次查看(过去 30 天)
显示 更早的评论
%Loop through columns, then rows
%j=1:n-1 because matrix is augmented and I only want to check the square matrix values; however, row operations should be performed on the entire row of the matrix
for j=1:n-1
for i=1:m
%if i=j, the code already performed an operation to transform the value to 1, so I want to skip matrix(i,j) if i=j
if i~=j
if matrix(i,j)~=0
if matrix(i,j)>0
matrix(i,:)=matrix(i,:)-matrix(i,j)*matrix(j,:);
elseif matrix(i,j)<0
matrix(i,:)=matrix(i,:)+(abs(matrix(i,j)))*matrix(j,:);
end
end
end
end
end
0 个评论
回答(1 个)
Sanjana Ramakrishnan
2017-5-8
Refer MATLAB source code for reference by typing the below command in MATLAB command window:
>>edit rref
You might also find the below file exchange link useful:
https://www.mathworks.com/matlabcentral/fileexchange/21583-fast-reduced-row-echelon-form
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!