randomly selection

i have 1e4 integer number from 1 to 1e4.how can i choose randomly any of these numbers each time?these 1e4 numbers are output of a code by this format X(1,i)and i=1 to 1e4 .now i want to select randomly one vector.

1 件のコメント

Krishna Kumar
Krishna Kumar 2011 年 6 月 23 日
what do you want exactly- a random permutation of the set of values or one value among them?

サインインしてコメントする。

回答 (2 件)

Krishna Kumar
Krishna Kumar 2011 年 6 月 23 日

0 投票

Do you have those values in a vector. If so, you can do like this-
random_chosen=V(randi([min(V) max(V)],1);
V=vector_of_integers.

3 件のコメント

milad babaei
milad babaei 2011 年 6 月 23 日
yes.my outputs are like this X(1,i)and i=1 to 1e4...and each vector contains a number .for example X(1,1)=2.4 and X(1,2)=230 ....X(1,1e4)=13.7...now i want to pick up randomly 1e4 vectors each time.(not in order)
Krishna Kumar
Krishna Kumar 2011 年 6 月 23 日
Is bobrov's answer not working for you
milad babaei
milad babaei 2011 年 6 月 23 日
this is my main problem.
http://mathworks.com/matlabcentral/answers/10043-calling-random-variables-and-using-them-in-a-loop
would u please help me ??

サインインしてコメントする。

Andrei Bobrov
Andrei Bobrov 2011 年 6 月 23 日

0 投票

1.
randi(1e4)
2. variant
X = randi(1e4,1,1e4);
% rendom index (idx) of vector X, length of vector Xout - 300
idx = randperm(1e4);
Xout = X(idx(1:300))
EDIT
doc rand
doc randi
doc randn
...
example
X = (b-a)*rand(1,1e4)+a;
% 'a' and 'b' interval random numbers
Matrix 'X1e4' [1e4x1e4] - 1e4 vectors (lines) with 1e4 elements
X1e4 = (b-a)*rand(1e4,1e4)+a;

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

質問済み:

2011 年 6 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by