random entry selection from a matrix
2 ビュー (過去 30 日間)
古いコメントを表示
how can I select any element randomly from a 1 x n matrix?
0 件のコメント
回答 (1 件)
Doug Hull
2012 年 7 月 23 日
v = [1:10]
vi = randi(numel(v));
choice = v(vi)
1 件のコメント
Walter Roberson
2012 年 7 月 23 日
Doug, you missed your chance to say
choice = v(randperm(numel(v),1));
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!