random entry selection from a matrix

回答 (1 件)

Doug Hull
Doug Hull 2012 年 7 月 23 日

0 投票

v = [1:10]
vi = randi(numel(v));
choice = v(vi)

1 件のコメント

Walter Roberson
Walter Roberson 2012 年 7 月 23 日
Doug, you missed your chance to say
choice = v(randperm(numel(v),1));

サインインしてコメントする。

カテゴリ

質問済み:

2012 年 7 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by