Create list of vector pairs from all possible permutations of two vectors

CaptainProg

I'm trying to achieve a relatively simple matrix manipulation in MATLAB.

From two vectors, I would like to generate all the possible two-element pairs that could be produced. For example, given the following two vectors:

a = [1 2 3]
b = [4 5 6]

... I would hope to be able to produce the following:

c =

     1     1     1     2     2     2     3     3     3
     4     5     6     4     5     6     4     5     6

I understand that I could generate the above using an explicit loop (such as multiple repmat() operations), but my previous experience of MATLAB suggests that there probably is a built-in function that can achieve this more quickly...

Any suggestions?

Daniel
a = [1 2 3]

a =

     1     2     3

>> b = [4 5 6]

b =

     4     5     6

>> c=allcomb(a,b)'

c =

     1     1     1     2     2     2     3     3     3
     4     5     6     4     5     6     4     5     6

You can find the allcomb function here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

algorithmic function to create all possible combinations from a list of vectors

From Dev

Generate all possible permutations for 2 vectors

From Dev

Create all possible Mx1 vectors from an Nx1 vector in MATLAB

From Dev

All possible permutations of words in different files in pairs

From Dev

Generate All Possible Permutations of Vector of Objects

From Dev

Create vector selecting values from two different vectors

From Dev

Getting difference from all possible pairs from a list Python

From Dev

Python merging two lists with all possible permutations

From Dev

Quaternion from two vector pairs

From Dev

Create all possible permutations of given variable set

From Dev

Replacing items in a list in all possible permutations

From Dev

How to make a list of pairs from 2 vectors

From Dev

Finding combinations of vectors from pairs of list items

From Dev

Merge two vectors and get a list of vector in R

From Dev

Generate all possible n choose 2 pairs from a vector in R, efficient and fast

From Dev

Get all unique combinations from list of permutations

From Dev

Get all unique combinations from list of permutations

From Dev

create vectors from vector of names and assign length

From Dev

List all possible combinations for a vector

From Dev

List all possible combinations for a vector

From Dev

How do I create two vectors from an existing vector (of characters) in R?

From Dev

Create one 16-bit vector from two 8-bit vectors

From Dev

Create all combinations of two vectors in R?

From Dev

Find Closest Vector from a List of Vectors | Python

From Dev

How to generate all possible combinations from all permutations?

From Dev

How to create a dataframe from a list of multiple vectors and non-vector elements in R?

From Dev

How can I generate a list of all possible permutations of several letters?

From Dev

Create a recursive list from a list of vectors

From Dev

Create a list from the last elements in vectors in a list

Related Related

  1. 1

    algorithmic function to create all possible combinations from a list of vectors

  2. 2

    Generate all possible permutations for 2 vectors

  3. 3

    Create all possible Mx1 vectors from an Nx1 vector in MATLAB

  4. 4

    All possible permutations of words in different files in pairs

  5. 5

    Generate All Possible Permutations of Vector of Objects

  6. 6

    Create vector selecting values from two different vectors

  7. 7

    Getting difference from all possible pairs from a list Python

  8. 8

    Python merging two lists with all possible permutations

  9. 9

    Quaternion from two vector pairs

  10. 10

    Create all possible permutations of given variable set

  11. 11

    Replacing items in a list in all possible permutations

  12. 12

    How to make a list of pairs from 2 vectors

  13. 13

    Finding combinations of vectors from pairs of list items

  14. 14

    Merge two vectors and get a list of vector in R

  15. 15

    Generate all possible n choose 2 pairs from a vector in R, efficient and fast

  16. 16

    Get all unique combinations from list of permutations

  17. 17

    Get all unique combinations from list of permutations

  18. 18

    create vectors from vector of names and assign length

  19. 19

    List all possible combinations for a vector

  20. 20

    List all possible combinations for a vector

  21. 21

    How do I create two vectors from an existing vector (of characters) in R?

  22. 22

    Create one 16-bit vector from two 8-bit vectors

  23. 23

    Create all combinations of two vectors in R?

  24. 24

    Find Closest Vector from a List of Vectors | Python

  25. 25

    How to generate all possible combinations from all permutations?

  26. 26

    How to create a dataframe from a list of multiple vectors and non-vector elements in R?

  27. 27

    How can I generate a list of all possible permutations of several letters?

  28. 28

    Create a recursive list from a list of vectors

  29. 29

    Create a list from the last elements in vectors in a list

HotTag

Archive