Effacer les filtres
Effacer les filtres

Specify number of ones in each row and column in binary matrix

1 vue (au cours des 30 derniers jours)
high speed
high speed le 3 Avr 2021
Commenté : high speed le 3 Avr 2021
I want create random binary matrix of dimensions 972x1944 that contain 3 ones in each column and 6 ones in each row.
How can I do that please

Réponse acceptée

Matt J
Matt J le 3 Avr 2021
A=kron(eye(324),ones(3,6));
A=A(randperm(972), randperm(1944));

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by