how to pick the pair of numbers?

조회 수: 5 (최근 30일)
Raja R
Raja R 2016년 1월 8일
답변: Joseph Cheng 2016년 1월 8일
I have a=[1 2 3 4 5 ]. I want to pick any type of pair as [Eg: p1=1,p2=2 p3=3 p4=2 . . . . . .] I want to get 5 pairs,upto p10 but the restriction is any pair should not be like this p1=1 p2=1 or 22 or 33 or 44 or 55.and another restriction is if 1pair is like p1=1 p2=4 then another pair should not contain p3=4 p4=1.

답변 (1개)

Joseph Cheng
Joseph Cheng 2016년 1월 8일
You can use the function nchoosek() (example: nchoosek(1:5,2))) so it has your array 1 through 5 and it'll supply the unique pairs.

카테고리

Help CenterFile Exchange에서 Discrete Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by