I have a 10 by 10 matrix with only value 0 and 1 in it. I want to set to infinite for elements who have a value of 0 and are not diagonal. But for code below, those elements are set to 1 instead of infinite. Any help will be appreciated.
for i = 1:10 for j = 1:10 if(A(i,j) == 0 && i~=j) A(i,j) = Inf; end end end
Best Answer