How to generate 0 and 1 matrix in specific condition.
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jenjen Ahmad Zaeni
am 28 Mai 2021
Kommentiert: Jenjen Ahmad Zaeni
am 29 Mai 2021
Hello everyone. I want to generate a random 4x5 matrix with the elements consist of 0 and 1. But, i don't want each column to have a total amount of 1 that is less than 2. So it's more like:
A =
0 1 1 1 0
1 1 1 1 1
1 1 1 0 1
0 0 1 0 1
I'm okay if there are 2, 3, or 4 total amount of '1' element, but i don't want even a single column to have only one '1' element, or zero at all. How to make it possible? Thank you very much.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!