randone1

バージョン 1.0.0.0 (1.02 KB) 作成者: Jos (10584)
random array with one 1 per row (and column)
ダウンロード: 25
更新 2016/6/17

ライセンスの表示

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)

引用

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

MATLAB リリースの互換性
作成: R2016a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCreating and Concatenating Matrices についてさらに検索
タグ タグを追加
謝辞

ヒントを得たファイル: shake, NTRUE, RANDSWAP

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0