2016-05-31 88 views
-2

如果我有一個包含11個元素的集合,並且想要在每個子集中包含3個選項的組合,我該如何編寫一個能夠以符號形式顯示所有可能組合的Matlab代碼?我知道使用\ math {\ factorial {n}/\ factorial {k} * \ factorial {n-k}}的可能組合數是165。我很感激有人能幫助我。 謝謝Matlab中的概率組合

+2

查找到['nchoosek'](http://www.mathworks.com/help/matlab/ref/nchoosek.html ),['perms'](http://www.mathworks.com/help/matlab/ref/perms.html),['randperm'](http://www.mathworks.com/help/matlab/ref /randperm.html)。 –

+2

歡迎來到Stack Overflow。請閱讀stackoverflow.com/help/how-to-ask瞭解如何編寫問題的指導原則。對於初學者:1.請格式化您的代碼。 2.在你的問題中添加更多代碼,以顯示你已經嘗試過的內容,併爲未來的讀者提供這個問題。 3.尋找可能已經幫助你的其他問題或文檔。例如http://in.mathworks.com/help/map/ref/combntns.html?requestedDomain=www.mathworks.com和http://in.mathworks.com/help/stats/combnk.html –

回答

0

嘗試:

 combos = combntns(set,subset) 

C = combnk(v,k)