필터 지우기
필터 지우기

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 CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by