How can I assign two sets of values randomly among two other sets?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (2개)
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))) ;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!