V_CHOOSRNK All choices of K elements taken from 1:N with replacement. [X]=(N,K) The output X is a matrix of size ((N+K-1)!/(K!*(N-1)!),K) where each row contains a choice of K elements taken from 1:N with duplications allowed. The rows of X are in lexically sorted order. To choose from the elements of an arbitrary vector V use V(CHOOSRNK(LENGTH(V),K)).

- v_choosenk V_CHOOSENK All choices of K elements taken from 1:N [X]=(N,K)

0001 function x=v_choosrnk(n,k) 0002 %V_CHOOSRNK All choices of K elements taken from 1:N with replacement. [X]=(N,K) 0003 % The output X is a matrix of size ((N+K-1)!/(K!*(N-1)!),K) where each row 0004 % contains a choice of K elements taken from 1:N with duplications allowed. 0005 % The rows of X are in lexically sorted order. 0006 % 0007 % To choose from the elements of an arbitrary vector V use 0008 % V(CHOOSRNK(LENGTH(V),K)). 0009 0010 % Copyright (c) 1998 Mike Brookes, mike.brookes@ic.ac.uk 0011 % Version: $Id: v_choosrnk.m 10865 2018-09-21 17:22:45Z dmb $ 0012 % 0013 % VOICEBOX is a MATLAB toolbox for speech processing. 0014 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0015 % 0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0017 % This program is free software; you can redistribute it and/or modify 0018 % it under the terms of the GNU General Public License as published by 0019 % the Free Software Foundation; either version 2 of the License, or 0020 % (at your option) any later version. 0021 % 0022 % This program is distributed in the hope that it will be useful, 0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0025 % GNU General Public License for more details. 0026 % 0027 % You can obtain a copy of the GNU General Public License from 0028 % http://www.gnu.org/copyleft/gpl.html or by writing to 0029 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 x=v_choosenk(n+k-1,k); 0032 x=x-repmat(0:k-1,size(x,1),1);

Generated by