Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

combinat::cartesianProduct

Cartesian product

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

combinat::cartesianProduct(S1, …)

Description

combinat::cartesianProduct(S1, ...) returns the cartesian product of the sets or lists S1, … as a list of lists.

The cartesian product of S1 through Sn consists of all lists of length n whose i-th entry is an operand of the set or list Si, for 1 ≤ in.

Any integer k among the arguments is identified with the set of the first k positive integers.

The ordering of the output is unspecified.

Examples

Example 1

The following calls are equivalent:

combinat::cartesianProduct({1, 2}, {a, b}), 
combinat::cartesianProduct(2, [b, a])

Parameters

S1

Set, list, or nonnegative integer

Return Values

List of lists, each of them having as many operands as there were arguments passed to combinat::cartesianProduct.

Was this topic helpful?