How can I create this matrix?

4 ビュー (過去 30 日間)
Sourasis Chattopadhyay
Sourasis Chattopadhyay 2021 年 8 月 4 日
コメント済み: Walter Roberson 2021 年 8 月 19 日
  1 件のコメント
KSSV
KSSV 2021 年 8 月 4 日
An example will hep us to help you.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2021 年 8 月 4 日
n = 5;
r = 2:5;
F = @(k)any(permute(nchoosek(1:n,k),[3,1,2])==(1:n).',3);
M = cell2mat(arrayfun(F,r,'uni',0))
M = 5×26 logical array
1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 1 1 0 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 1 1 1
  4 件のコメント
Sourasis Chattopadhyay
Sourasis Chattopadhyay 2021 年 8 月 19 日
Thank you for you answer .
Walter Roberson
Walter Roberson 2021 年 8 月 19 日
You might be able to fit the 50 case. Change to
F = @(k)any(permute(nchoosek(uint8(1:n),k),[3,1,2])==uint8(1:n).',3);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by