MATLAB: How to add rows of data in a 5×5 Matrix

add row of matrix;

Hi, I want to add entries in each row and put zero in the Inf place but I want to use for loop? I tried this
if true
A = sum(A,2);
end
But I am want to put entries equal to Inf to zero and then add them.

Best Answer

If you want to replace the inf values with 0 first, then
A(isinf(A)) = 0;