I need to generate all 0/1 matrices
Mostra commenti meno recenti
Hi, i would like to generate all different 5x5 triangle matrices which just have 0 and 1 as elements.
It's important that i really get all and not just a lot.
Is there a command for it? If not how can i programm it?
I appreciate your help a lot.
1 Commento
Jan
il 3 Lug 2013
Risposta accettata
Più risposte (2)
%This will flip through the linear indexes of a matrix and turn each value into % a binary one
A = rand(5)
for p=1:end
if A(p)<=.5
A(p)= 0
else
A(p)=1
end
end
Edit: triu(A) and tril(A) return the upper and lower triangular portions of A, respectively. Tack that onto my previous post and you should be all set.
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!