フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

could anyone tell me how to group the combinations under the condition that the same number should not be repeated again.

2 ビュー (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2018 年 3 月 23 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
code: c = combnk(1:4,2)
If i run it i am getting c =
3 4
2 4
2 3
1 4
1 3
1 2
could anyone help me how to group the numbers say for example (34,12),(24,13) and (23,14) in the following way.

回答 (2 件)

KSSV
KSSV 2018 年 3 月 23 日
c = combnk(1:4,2) ;
N = sum(c.*[10 1],2) ;
iwant = [N(1:3) N(length(N):-1:4)]
  7 件のコメント
Prabha Kumaresan
Prabha Kumaresan 2018 年 3 月 23 日
what should be done in case of 2015b.

Rik
Rik 2018 年 3 月 24 日
編集済み: Rik 2018 年 3 月 24 日
The code below is the same as the code by KSSV, but without the need for implicit expansion.
c = combnk(1:4,2);
N = c * [10;1];
iwant = [N(1:3) N(length(N):-1:4)];
  4 件のコメント
Prabha Kumaresan
Prabha Kumaresan 2018 年 3 月 26 日
ok.But i want to group the numbers (3 4,1 2),(2 4,1 3) and (2 3,1 4) in this manner.I dont want to have command line. N = c * [10;1 ] as it does product and sum. I just want to group the numbers.
Walter Roberson
Walter Roberson 2018 年 3 月 26 日
Your question ends with "in the following way." without an example of the output you want.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by