Enter two numbers to generate a regular sequence

1 回表示 (過去 30 日間)
Yang Metin
Yang Metin 2020 年 7 月 24 日
編集済み: Arthur Roué 2020 年 7 月 24 日
How to generate the following series:
(A means the largest number in the sequence, D means the length of the result sequence. Please see the example below for specific rules)
A=4, D=2:
The result is [1 2],[1 3],[1 4],[2 3],[2 4],[3 4].
A=6, D=2:
The result is [1 2],[1 3],[1 4],[1 5],[1 6],[2 3],[2 4],[2 5],[2 6],[3 4],[3 5],[3 6],[4 5],[4 6],[5 6].
A=5, D=3:
The result is [1 2 3],[1 2 4],[1 2 5],[1 3 4],[1 3 5],[1 4 5],[2 3 4],[2 3 5] ,[2 4 5],[3 4 5].
A and D are input values.

採用された回答

Arthur Roué
Arthur Roué 2020 年 7 月 24 日
編集済み: Arthur Roué 2020 年 7 月 24 日
nchoosek(1:A, D)
Here a link to nchoosek documentation.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by