Random symmetric binary matrix
이전 댓글 표시
I want to make a symmetric (100x100) matrix with binary values and the numbers on the diagonal have to be 0. Can anyone help me?
답변 (1개)
Star Strider
2016년 11월 28일
See if this does what you want:
N = 6; % Matrix Size
M = randi([0 1], N);
Mu = triu(M);
Ml = Mu';
Mout = Mu + Ml;
Mout = Mout - diag(diag(Mout))
I kept the matrix size small here so you can verify that it does what you want. Change it to 100 for your matrix.
카테고리
도움말 센터 및 File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!