Generate random's number?

1 次查看(过去 30 天)
Edoardo
Edoardo 2012-10-31
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
out=stream(randi(length(stream)));

更多回答(1 个)

José-Luis
José-Luis 2012-10-31
nVals = numel(your_stream);
your_val = your_stream(randperm(nVals,1));

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by