using rand to generate three different numbers

for q = 1:50000
ii = int8(rand* 10);
jj = int8(rand* 10);
kk =int8(rand* 10);
if(ii ~= jj && jj ~= kk)
disp('program convereged early');
break;
end
ii
jj
kk
end
here I want the different values of ii, jj, kk for a single run(means if ii=1 then jj and kk cant be 1, they must be different from each other and I want the values of ii, jj, kk in between 1 and 10, it can be 1 or 10 but not 0. and the values of ii, jj, kk should not match with the no of iteration.for example if q=1 then ii, jj, kk cant be 1.

1 件のコメント

Walter Roberson
Walter Roberson 2014 年 3 月 31 日
You might prefer to use randi()

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

質問済み:

2014 年 3 月 31 日

コメント済み:

2014 年 3 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by