필터 지우기
필터 지우기

how to find random number between 20 input numbers

조회 수: 1 (최근 30일)
Maryam Abdirad
Maryam Abdirad 2017년 11월 19일
답변: Walter Roberson 2017년 11월 19일
I have 20 numbers that I want to find 1 or 2 or 3 of them as random. Could you help me to write code or any function that generate random number?

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 19일
L = length(YourVectorOfNumbers);
num_to_pick = randi(3);
which_to_pick = randperm(L, num_to_pick);
picked_values = YourVectorOfNumbers(which_to_pick);

추가 답변 (0개)

카테고리

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