Gauss Elimination - making my upper triangular matrix
Show older comments
Hi I was trying to figure out how to make the upper triangular matrix for a matrix of unspecified length (nxn), but my line 7 keeps getting an error and I can't seem to figure out why. Please help thank youu and my code is below!!
function[x]=Gauss(a,b)
B=[a b];
n=length(b);
for j= 1:n
B=sortrows(B(j:n),'descend');
for i=j+1:n
B(i,:)=B(i,:)-((B(i,j)*B(j,:))/B(j,j));
end
end
Errors:
Index in position 1 exceeds array bounds. Index must not exceed 1.
Error in Gauss (line 7)
B(i,:)=B(i,:)-(B(i,j)/B(j,j))*B(j,:);
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!