randone1

random array with one 1 per row (and column)

Ahora está siguiendo esta publicación

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)

Citar como

Jos (10584) (2026). randone1 (https://es.mathworks.com/matlabcentral/fileexchange/57725-randone1), MATLAB Central File Exchange. Recuperado .

Agradecimientos

Inspirado por: shake, NTRUE, RANDSWAP

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y MATLAB Answers.

Información general

Compatibilidad con la versión de MATLAB

  • Compatible con cualquier versión

Compatibilidad con las plataformas

  • Windows
  • macOS
  • Linux
Versión Publicado Notas de la versión Action
1.0.0.0