ram issue while generating subsets
이전 댓글 표시
alright, I wrote a code in matlab which in a part of that it needs to generate all subsets of a vector and process all of them one by one. For example having vector X, I first used the function combntns(X, k) to generate the subsets but there is a problem that X can be in a very high dimension so to save the all subsets of X it requires massive amount of ram! And I always run out of ram memory while running the code. That is so unnecessary to save all the subsets since the algorithm will process them one by one. I wonder is there any function to do this for me or I have to write a code manually to do so?
채택된 답변
추가 답변 (1개)
ok, I don't need ALL subsets I have a limit for subset size for example ALL subsets with length 3
If the length of the subset is small (typically around 3 if that's what you're saying), then nchoosek should give you what you're looking for pretty easily and without too much strain in memory,
Xsubsets=nchoosek(X,3);
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!