Q:

finding minimum number in each matrix row

I am attempting to write a code to find a minimum number from the 'distance' matrix, excluding zeroes from the matrix. 
distance=[0    0.44    0.40    0.63    0.89
0.44    0       0.44    0.72    1.00
0.40    0.44    0       0.28    0.56
0.63    0.72    0.28    0       0.28
0.89    1.00    0.56    0.28    0]

for  i=1:Nodes
    for  j=1:Nodes
        if (distance(i,j)~=0)

        [mini(i,:)]=[min(distance(i,:))];
        end
    end
end

Any help is appreciated! Thank you!

A:

The correct answer is:
d = distance;
d(~d) = inf;
mini = min(d);

First you get rid of the zero entries, then you let Matlab calculate the minimum per row.
You should always try to avoid loops in Matlab.

