I got a problem about checking if two matrices are equal in MATLAB.
Specifically, I want to verify if, for a matrix W
, all elements are equal to each other and all row sums are equal to 1 we would have W = W^2
.
Therefore I wrote the following code which aims to check if every element of these two matrices are equivalent, to conclude whether the matrices are equal to each other. But it turns out that this does not work since the W8
matrix should be equal to its square.
for i = 1 :60
for j = 1 :60
if(W8(i,j) - W8_square(i,j) ~= 0)
disp('the matrix are not equal');
break;
end
end
end