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.


Cardinality of a set

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.




card(set) returns the cardinality of set.

If set is a DOM_SET, the number of operands is returned; card does not attempt to investigate whether the members of set really represent pairwise different mathematical objects.

card does not distinguish different infinite cardinals; it just returns infinity if set is infinite.

card returns a symbolic call to itself if it cannot determine the cardinality.

If applied to a domain d, card returns the domain entry d::size. A domain that does not have this entry is not regarded as a set.


Example 1

The cardinality of a finite set equals the number of its operands:

card({1, 2, 3})

This holds true even if there exist two operands of the set that represent the same mathematical object:

card({1, 1.0})

Example 2

card does not distinguish different sizes of infinite sets:

card(R_), card(Z_)

Example 3

Set-theoretic expressions containing symbols are legal input, but usually card will not be able to determine their cardinality:

card(S union {3})

Example 4

Domains that have a "size" entry are regarded as sets:




A set of type DOM_SET, or a set-theoretic expression


A domain representing a set

Return Values

Nonnegative integer, or infinity.

Overloaded By

d, set

See Also

MuPAD Functions

Was this topic helpful?