randone1

random array with one 1 per row (and column)
25 download
Aggiornato 17 giu 2016

Visualizza la licenza

randone1 - produces a random array with one 1 per row and column
randone1(N) returns a N-by-N square array with zeros and N ones,
randomly distributed so that each row and each column contains a one 1.

randone1(N,M) where M > N returns a N-by-M array with zeros and N ones,
again with one 1 per row, randomly distributed over the M columns.

Examples
randone1(4,5)
% could yield [0 1 0 0 0 ; 0 0 0 1 0 ; 0 0 0 0 1 ; 0 0 1 0 0]

See also rand, randperm, sort,
nones, randswap (File Exchange)

Cita come

Jos (10584) (2024). randone1 (https://www.mathworks.com/matlabcentral/fileexchange/57725-randone1), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2016a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e MATLAB Answers
Riconoscimenti

Ispirato da: shake, NTRUE, RANDSWAP

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0