Choose function too slow

Dear All,
i try to run
index=nchoosek(1:200, 10);
it talks a lot of time
is there exist any code that can be more faster.
Thanks in Advance.

답변 (4개)

Image Analyst
Image Analyst 2012년 9월 3일

1 개 추천

Look at the number of rows it would return:
>> factorial(200)./(factorial(200-10)* factorial(10))
ans =
NaN
>> factorial(200)
ans =
Inf
What do you really want to do. I doubt you need to do it this way. Perhaps rand or randperm might work for you.

댓글 수: 1

Walter Roberson
Walter Roberson 2012년 9월 3일
The number of possibilities is about 2.2E+16

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2012년 9월 3일

1 개 추천

An array that large cannot be done on any platform supported by MATLAB. It is 22451004309013280 outputs, each 10 entries long. Now, 200 is a number that fits within 8 bits so in theory the individual entries could be a single uint8 (a byte each); that still requires 2^(57.64) bytes of memory. No released x86 CPU has been designed that uses more than 48 bits of memory addressing, so your problem is 2^(ceil(57.64)-48) = 1024 times larger than is possible on any supported platform at this time.
Jan
Jan 2012년 9월 3일

0 개 추천

FEX: VChooseK is much faster than Matlab's nchoosek. But for your job a really large memory is required. So think twice if you really need such a giantic array.
Hassan
Hassan 2012년 9월 3일

0 개 추천

Thanks for your replay.
when i use VChooseK, Error in compiler for matlab R2012a
No supported SDK or compiler was found on this computer. For a list of supported compilers, see http://www.mathworks.com/support/compilers/R2012a/win64.html
Error using mex (line 206) Unable to complete successfully.

댓글 수: 2

Walter Roberson
Walter Roberson 2012년 9월 3일
So see that URL and load in a compiler and SDK.
Jan
Jan 2012년 9월 4일
You find several threads about installing a compiler in this forum.
Did you follow my advice to think twice?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

태그

질문:

2012년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by