Hello,
I want to generate a matrix that has in every row one element set to one. However, the numbers on the diagonals should not be one.
This is the code I have now. However, j can not be equal to i, but I don't know how to exclude i from generating j.
W = zeros(N,N);
for i = 1:N
j = randi(N);
W(i, j) = 1;
end
I hope someone can help! Thanks in advance 🙂
Best Answer