how to set elements in a matrix to infinite

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

1 Comment

What is the type of "A".
Is it logical (boolean)?

Sign in to comment.

 Accepted Answer

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!