How can I assign two sets of values randomly among two other sets?

조회 수: 4 (최근 30일)
Bhavya Gandham
Bhavya Gandham 2016년 10월 7일
댓글: KSSV 2016년 10월 8일
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.....

답변 (2개)

KSSV
KSSV 2016년 10월 7일
편집: KSSV 2016년 10월 7일
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))) ;

Bhavya Gandham
Bhavya Gandham 2016년 10월 7일
Hi! Thanks for the answer. But I need to randomly interchange the total 2 sets between other two sets. like, first a(set of 100 values) is assigned to s1 , b(a set of 100 values) assigned to s2 and in the next run it have to assign a to s2, b assigned to s1. And here a and b randomly generates 100 values with a's range (0,0.7) and b's range (0.7,1.2) Thanks in advance...

카테고리

Help CenterFile Exchange에서 ROC - AUC에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by