Generate random's number?

Hi;
How can I create a random's stream that generated only one number?
Exemple;
I have this strema 0,40,80,110,150,180.... I would like that to have a variable rappresented by one number choosed randomly from the stream.
Thanks Edoardo

 채택된 답변

Matt J
Matt J 2012년 10월 31일

1 개 추천

out=stream(randi(length(stream)));

추가 답변 (1개)

José-Luis
José-Luis 2012년 10월 31일

1 개 추천

nVals = numel(your_stream);
your_val = your_stream(randperm(nVals,1));

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

제품

질문:

2012년 10월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by