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일

4 개 추천

entry = vector(randi(length(vector)));

추가 답변 (1개)

the cyclist
the cyclist 2015년 8월 28일

1 개 추천

If you have the Statistics and Machine Learning Toolbox, you can use the datasample function.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

Lou
2015년 8월 28일

답변:

2015년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by