-2

I want to access to row i of A=nchoosek(1:m,n). This command of MATLAB is very time consuming, specially for large m. So, I do not want to construct whole of A. I want to build just rowi of A.

Although, it seems that my question is duplicate of "Combinations from a given set without repetition", but they are different.

That answer did not cover different columns. It is just get acceptable results for A = nchoosek(M,2). I want to find A (i,:), where A= nchoosek(1:m,n), for given i, m, and n.

Community
  • 1
  • 1
Meher81
  • 161
  • 1
  • 8

1 Answers1

1

This answer answers the original version of the question, not the updated version

This is exactly what nchoosek does, when you input a vector.

nchoosek([1:n],m)

.

>> m=2

m =

     2

>> n=5

n =

     5

>> nchoosek([1:n],m)

ans =

     1     2
     1     3
     1     4
     1     5
     2     3
     2     4
     2     5
     3     4
     3     5
     4     5
Daniel
  • 36,610
  • 3
  • 36
  • 69
  • Yes, but I do not want to use `nchoosek([1:n],m)`. In my real code, n could be very large. As, depends on m and n, I need just one column of `A=nchoosek([1:n],m)`, I want to construct the desire vector in a different way. Using `nchoosek([1:n],m)` for large `n` is very time consuming, and require a lot of memory. – Meher81 Apr 18 '15 at 09:08
  • 1
    @Meher81: Please update your question and explain what you really want. Your question says you want `A` and not just one column of `A` – Daniel Apr 18 '15 at 09:09