MATLAB: How to find a combination like this combinatorics I am wondering is there a way where I could use a matrix in combinatorics such as nchoosek(4,1:4) where it calcluates 4choose1, 4choose2,… 4choose4 ? Is thie possible in Matlab? Best Answer N = 4;temp = factorial(0:N);temp(end) ./ (temp .* fliplr(temp))This would be 4C0, 4C1, 4C2, 4C3, 4C4, so you could index into the result to get the subset you need. Related SolutionsMATLAB: How to save matrix created in each iteration One of waysn=1;k=[1 2 3 4;5 6 7 8];out = zeros([size(k),3]);while n<4 k=k*n; out(:,:,n) = k; n=n+1;end MATLAB: How to generate all possible combinations from multiple sets of nchoosek In case anyone else ever stumbles upon this question...I figured out how to solve my problem. Use a combination of nchoosek and combvec:c1 = nchoosek(n1,k1);c2 = nchoosek(n2,k2);c = combvec(c1',c2')';To order the rows in the same way as shown in the question, use:csorted = sortrows(c); Related QuestionFactorial of a number up to nHi, I have 2 columns data, In that every 1 column data of 1000 value (like 1.2345). i have split this data into (1 to 30), (1 to 60),so on (1 to 990).Zero value in beronoulli trials !!!
Best Answer