hi
i have a series of numbers and i want to select one of them randomly . ie
a=[10 3 4 2 5]
ans: 3
and at every time this may change to new number among them. kindly help in this regard. i will b highly thankful to you
Regards

 採用された回答

Ken Atwell
Ken Atwell 2015 年 6 月 14 日

0 投票

>> a(randi(numel(a)))
In other words, pick a random (integer) number N between 1 and the number of elements in "a", then return the Nth element of "a".

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by