채택된 답변

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?
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 .
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 Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by