Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3985384
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:53:03+00:00 2026-05-20T05:53:03+00:00

My question is Matlab related. There exist a fnct named nchoosek([vector],integer). By using this

  • 0

My question is Matlab related. There exist a fnct named nchoosek([vector],integer). By using this function I would like to get all 2-elements combinations of the given vector. (i.e nchoosek([1:10000, 2])). This is very slow, as stated in matlab documentation.

The question is : “Is there a faster way to do the same job?”.

Thank you for your time I really appreciate your efforts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:53:03+00:00Added an answer on May 20, 2026 at 5:53 am

    If it’s only 2-element combinations you need, you can use NDGRID. Note that all two-element combinations up to N require N^2 values, so if Matlab starts paging, the process will be slow.

    N = 100;
    [xx,yy] = ndgrid(1:N,1:N);
    allCombinations = [xx(:),yy(:)];
    

    Please be aware that the function NDGRID differs significantly from nchoosek.
    The former returns a double-row vector with all possible N^2 combinations, while the latter is leaving out combinations of two times the same element, as well as combinations where just the order is changed. Leading to just (N^2-N)/2 row elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to How can I merge this data in MATLAB? how
I don't know is this question more related to mathematics or programming and I'm
This may sound like a bit of a rhetorical question, but I ask it
This is a question about incrementing one value of a MATLAB array multiple times
My question is a possible duplicate of this: matlab mex files and C++ dll
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Question Is there a way to have a method that will always run anytime
My question is related with the previous solved question in How to save data
In the recent question How to organize MATLAB code? Andrew Janke mentioned in his
I would like to remove/delete a migration file. How would I go about doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.