1 件のコメント

KSSV
KSSV 2021 年 8 月 4 日
An example will hep us to help you.

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

 採用された回答

Stephen23
Stephen23 2021 年 8 月 4 日

1 投票

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 月 18 日
When I am running this code for n = 50 or 100 (n>25) In this case I am gettiing this type of error . What should I do?
Walter Roberson
Walter Roberson 2021 年 8 月 18 日
For n = 100, you want a 100 x (100C7)) matrix, at least. That would require
space = 100 * nchoosek(sym(100),sym(7))
space = 
1600756080000
Gb = vpa(space/2^30,6)
Gb = 
1490.82
close to 1.5 terabytes, at least, even in the best case situation (no intermediate arrays of notable size.)
If your system cannot handle 32 gigabytes, what is your plan to handle 45 times as much memory (at minimum, if no duplicate copies have to be made for temporary computations) ?
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 件)

カテゴリ

ヘルプ センター および File ExchangeSpline Postprocessing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by