フィルターのクリア

pick a random entry from a vector

5 ビュー (過去 30 日間)
Lou
Lou 2015 年 8 月 28 日
回答済み: the cyclist 2015 年 8 月 28 日
Hello, is there a matlab function that picks a random entry from a vector? I solved the problem with
i=randperm(length(vector),1),
entry=vector(i).
But i wondered if there is a more elegant solution. Thank you

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 28 日
entry = vector(randi(length(vector)));

その他の回答 (1 件)

the cyclist
the cyclist 2015 年 8 月 28 日
If you have the Statistics and Machine Learning Toolbox, you can use the datasample function.

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by