MATLAB: How i can remove inf value and zero value in 10×10 Matrix

matrix manipulationupper and lower triangular matrix removal

Hi, I want to remove the highlight red data from the 10×10 matrix and also the index (i=j) which is inf.? Need your guidance. One more thing I want to extract the indices where the value is non zero?

Best Answer

I assume you want the finite values which are not zero?
A % input Matrix
nonZeroValues = A(A~=0 & isfinite(A));
to get the indices you can run
ind = find(A~=0 & isfinite(A))
[row col] = ind2sub(size(A), ind)