Random combination between 2 arrays

조회 수: 4 (최근 30일)
Raj Arora
Raj Arora 2021년 9월 8일
댓글: Raj Arora 2021년 9월 8일
Suppose I have 2 arrays
X1 = 2.23 2.90 3.04 3.81
X2 = 0.51 0.55 0.61 1.5
Now I have to make the random combination of both these arrays(X1 & X2) such that the element must not repeat like the one given below
(2.23, 0.55); (2.90, 1.5); (3.04, 0.61); (3.81, 0.5)
Thanks in advance..

채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 8일
X1 = [2.23 2.90 3.04 3.81];
X2 = [0.51 0.55 0.61 1.5];
output = [X1(randperm(4)); X2(randperm(4))].'
output = 4×2
3.0400 0.6100 2.9000 0.5500 2.2300 0.5100 3.8100 1.5000
  댓글 수: 1
Raj Arora
Raj Arora 2021년 9월 8일
Thanks walter for you prompt reply

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by