- Why do you need this?
- What are m and n?
unable to print out the all possible answers, Out of memory and Maximum variable size allowed by the program is exceeded.
조회 수: 3 (최근 30일)
이전 댓글 표시
Hey all, I have a code here to generate all the possible combinations of a binary sequence consisting m zeroes and n one. Input : m and n value, output the corresponding combinations of the binary sequence. When I input small values of m and n, the code works fine, but when i input some big values of m and n. The matlab output Out of memory. Type HELP MEMORY for your options.
Error in unique>uniqueR2012a (line 623) groupsSortA = sortA(1:numRows-1,:) ~= sortA(2:numRows,:);
Error in unique (line 147) [varargout{1:nlhs}] = uniqueR2012a(varargin{1},logical(flaginds(1:5)));
Error in randbinary (line 19) x1=unique(perms([zeros(1, m) ones(1, n)]), 'rows')
Error using perms (line 24) Maximum variable size allowed by the program is exceeded. The following is my code(helped by someone in matlab answers) to print out all the unique possible combinations: x1=unique(perms([zeros(1, m) ones(1, n)]), 'rows') Could anyone tell me why it is Out of memory and Maximum variable size allowed by the program is exceeded? and how to fix it.
댓글 수: 5
Image Analyst
2014년 12월 2일
Bear, that's not an answer to Sean's "Why" - you merely repeated what you think you want to do. What he's getting after is that perhaps it's possible to do what you want to do in a different way that doesn't require all of the possible combinations being in memory at exactly the same time. Plus you didn't answer what m and n are.
Stephen23
2014년 12월 2일
Try buying a computer with infinite memory. That usually solves this kind of problem.
채택된 답변
matt dash
2014년 12월 2일
The maximum allowed variable size is very large. There is no practical reason to print all combinations if it exceeds this size. You would just have a very very large amount of text that will be useless to both people and computers.
In any case, the reason it's printing nothing is that the max variable size is being exceeded by the PERMS function, so the error occurs before it starts printing the output of the UNIQUE function.
Rather than using unique(perms()) you should be using the "C" output option of nchoosek, which does the same thing without all the overhead. But as the documentation notes, this will still generally only work when you have fewer than 15 items in your sequence.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!