COMBN (4.2)
by Jos (10584)
15 Mar 2005
(Updated 04 Apr 2011)
All combinations of N elements taken from the vector V.
|
Watch this File
|
| File Information |
| Description |
COMBN - all combinations of elements
M = COMBN(V,N) returns all combinations of N elements of the elements in
vector V. M has the size (length(V).^N)-by-N.
[M,I] = COMBN(V,N) also returns the index matrix I so that M = V(I).
V can be an array of numbers, cells or strings.
Example:
M = COMBN([0 1],3) returns the 8-by-3 matrix:
0 0 0
0 0 1
0 1 0
0 1 1
...
1 1 1
All elements in V are regarded as unique, so M = COMBN([2 2],3) returns
a 8-by-3 matrix with all elements equal to 2.
NB Matrix sizes increases exponentially at rate (n^N)*N.
See also PERMS, NCHOOSEK
and ALLCOMB, PERMPOS here on the FEX
Latest version 4.2 (apr 2011) |
| Acknowledgements |
This submission has inspired the following:
N_PERMUTE_K, VChooseKRO, de Bruijn sequence generator, Kautz sequence generator
|
| MATLAB release |
MATLAB 7 (R14)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (32) |
| 23 May 2005 |
Jamie Baier
|
|
|
| 25 May 2005 |
Jos vdG
|
|
|
| 18 Oct 2005 |
yakir gagnon
|
|
|
| 28 Oct 2005 |
Richard Vance
|
|
|
| 21 Jan 2006 |
David Torres
|
|
|
| 17 Jun 2006 |
Jürgen Womser-Schütz
|
|
|
| 11 Jul 2006 |
Peter Navé
|
|
|
| 25 Jul 2006 |
B E
|
|
|
| 01 Nov 2006 |
Vangelis R
|
|
|
| 16 Jan 2007 |
ShenKae Wu
|
|
|
| 21 Feb 2007 |
Wolfgang Zieroth
|
|
|
| 03 Apr 2007 |
Kaijun Wang
|
|
|
| 08 May 2007 |
Jos the author
|
|
|
| 24 Aug 2007 |
Ohad N
|
|
|
| 15 Jan 2008 |
Antonio Silva
|
|
|
| 09 Apr 2008 |
Riccardo Bevilacqua
|
|
|
| 06 May 2008 |
jose caceres
|
|
|
| 23 Mar 2009 |
Carlos Baiz
|
|
|
| 14 Dec 2009 |
Philip L
|
|
|
| 16 Jan 2010 |
Jan Simon
|
|
|
| 21 Jan 2010 |
Oleg Komarov
|
|
|
| 21 Dec 2010 |
John D'Errico
|
|
|
| 11 Apr 2011 |
Fabio
|
|
|
| 25 May 2011 |
Brad Ridder
|
|
|
| 29 May 2011 |
Manu
|
|
|
| 22 Jul 2011 |
W. Owen Brimijoin
|
|
|
| 05 Aug 2011 |
Talaria
|
|
|
| 09 Aug 2011 |
Jos (10584)
|
|
|
| 23 Mar 2012 |
Marc Lalancette
|
|
|
| 25 Mar 2012 |
Jos (10584)
|
|
|
| 04 Apr 2012 |
Han
|
|
|
| 03 Jun 2012 |
mya
|
|
|
| Updates |
| 11 May 2006 |
new faster algorithm |
| 31 Aug 2006 |
new (very fast) algorithm |
| 08 May 2007 |
arggg updated with older version ... |
| 07 May 2008 |
fast algorithm |
| 18 Jan 2010 |
modified slightly based on suggestions by Jan Simon (thanks!) |
| 04 Apr 2011 |
corrected to give column vector output for N=1. (error pointed out by Wilson via email). |
|
Contact us at files@mathworks.com