How can I assign two sets of values randomly among two other sets?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two sets a and b, these sets of values to another two sets s1 and s2. I tried for randperm but i am getting errors. Thanks in advance.....
0 Kommentare
Antworten (2)
KSSV
am 7 Okt. 2016
Bearbeitet: KSSV
am 7 Okt. 2016
Using randsample
% Create two sets
a = rand(10,1) ;
b = rand(20,1) ;
% Assign to s1, s2 randomly
s1 = randsample(a,length(a)) ;
s2 = randsample(b,length(b)) ;
Using randperm
% Create two sets
a = rand(10,1) ;
b = rand(20,1) ;
% Assign to s1, s2 randomly
s1 = a(randperm(length(a))) ;
s2 = b(randperm(length(b))) ;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Entering Commands finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!