Generate a rondom sequence

11 Ansichten (letzte 30 Tage)
abdulhakeem
abdulhakeem am 15 Mär. 2013
Greetings,
Please can any one help me about:
How to Generate Generate a random sequence Z ={(i, j)},
where i, j Belongs to {1, 2, 3, 4}, i not equal to j
i and j are selected randomly.
Best Regards

Akzeptierte Antwort

Youssef  Khmou
Youssef Khmou am 15 Mär. 2013
or you can try :
a=1:4;
v=perms(a); % ALL possible combinations
Z=[v(:,1:2);v(:,3:4)];% Z is 2 columns
  2 Kommentare
Cedric
Cedric am 15 Mär. 2013
+1
abdulhakeem
abdulhakeem am 15 Mär. 2013
Dear Youssef KHMOU,
Thank you very much that is exactly I want. I appreciate That.
Best Regards

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Youssef  Khmou
Youssef Khmou am 15 Mär. 2013
Bearbeitet: Youssef Khmou am 15 Mär. 2013
hi,
Random sequence derived from which distribution ?
Z=rand(4); % from Uniform distribution.
Z=randn(4); % from Normal distribution.
Z=random('rayl',(1:4)'*(1:4)) % from Rayleigh distribution

Cedric
Cedric am 15 Mär. 2013
Bearbeitet: Cedric am 15 Mär. 2013
A basic approach, but dangerous as you don't know how much time it will take, could be..
ii = randi(4, 4, 1) ;
jj = randi(4, 4, 1) ;
while any(jj == ii)
jj = randi(4, 4, 1) ;
end
Z = [ii, jj]
If you don't want repetitions within ii or jj, you can use RANDPERM.
  1 Kommentar
abdulhakeem
abdulhakeem am 15 Mär. 2013
Thank you I appreciate your help

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by