## How do you do a Cartesian product in Matlab?

X = CARTPROD(A,B,C,…) returns the cartesian product of the sets A,B,C, etc, where A,B,C, are numerical vectors. This function requires IND2SUBVECT, also available (I hope) on the MathWorks File Exchange site.

What is the formula for Cartesian product?

The Cartesian square of a set X is the Cartesian product X2 = X × X. An example is the 2-dimensional plane R2 = R × R where R is the set of real numbers: R2 is the set of all points (x,y) where x and y are real numbers (see the Cartesian coordinate system).

What is the product of Cartesian product?

In mathematics, the Cartesian Product of sets A and B is defined as the set of all ordered pairs (x, y) such that x belongs to A and y belongs to B. For example, if A = {1, 2} and B = {3, 4, 5}, then the Cartesian Product of A and B is {(1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)}.

### How do you find the product in Matlab?

B = prod( A ) returns the product of the array elements of A .

1. If A is a vector, then prod(A) returns the product of the elements.
2. If A is a nonempty matrix, then prod(A) treats the columns of A as vectors and returns a row vector of the products of each column.
3. If A is an empty 0-by-0 matrix, prod(A) returns 1 .

What is the Cartesian product of A ={ 1 2 and B ={ a B?