values of randi function repeat themselves

2 次查看(过去 30 天)
while using the function randi that generate random integers uniformly disterbuted i sometimes get in the output vector the same numbers for example:
4 2 5 3 4 8 7 9 7 4
(the number 4 was three times in the row above)
how can i avoid this?
locTX=randi([1 20],1,4);

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-8-30
编辑:Azzi Abdelmalek 2014-8-30
Use randperm function
  4 个评论
Kobi
Kobi 2014-8-31
i use randi not randni
about the other quastion how does the random numbers distributed? uniformly?
Image Analyst
Image Analyst 2014-8-31
rand() and randi() are uniform. randn() is normally/Gaussian distributed. You might want to edit your post (body and subject line) to get rid of randni to avoid confusing people with a function that you say you don't use.

请先登录,再进行评论。

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by