QuantityQ

QuantityQ[expr]

gives True if expr is a Quantity with valid arguments, and False otherwise.

QuantityQ[expr,dims]

gives True if expr is a Quantity with physical dimensions dims, and False otherwise.

Details

  • QuantityQ[expr] returns False unless expr is a Quantity expression with valid arguments (i.e. has a canonical unit).
  • QuantityQ[expr,dims] returns True if expr is a valid Quantity and is compatible with dims.
  • Dimensional specification dims may be a list of unit dimensions, a QuantityVariable, a Quantity or a string representing a quantity variable or unit dimension.

Examples

open allclose all

Basic Examples  (2)

QuantityQ tests whether an object is a Quantity with valid arguments:

Test if an expression is a time quantity:

Scope  (3)

Dimension specifications may be a list of unit dimensions, QuantityVariable, Quantity or string:

QuantityQ returns False if the first argument is not a valid Quantity expression:

QuantityQ returns False if the second argument is not a recognized dimension specification:

Applications  (1)

QuantityQ can be used in pattern tests for functions:

Properties & Relations  (3)

QuantityQ returns False for any expression whose head is not Quantity:

In particular, QuantityArray, QuantityVariable, and QuantityDistribution are not QuantityQ objects:

QuantityQ returns False for Quantity expressions with invalid arguments:

QuantityQ returns True only for Quantity expressions with valid arguments:

Possible Issues  (1)

Dimension specifications may not be a unit:

Wolfram Research (2012), QuantityQ, Wolfram Language function, https://reference.wolfram.com/language/ref/QuantityQ.html (updated 2024).

Text

Wolfram Research (2012), QuantityQ, Wolfram Language function, https://reference.wolfram.com/language/ref/QuantityQ.html (updated 2024).

CMS

Wolfram Language. 2012. "QuantityQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/QuantityQ.html.

APA

Wolfram Language. (2012). QuantityQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/QuantityQ.html

BibTeX

@misc{reference.wolfram_2024_quantityq, author="Wolfram Research", title="{QuantityQ}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/QuantityQ.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_quantityq, organization={Wolfram Research}, title={QuantityQ}, year={2024}, url={https://reference.wolfram.com/language/ref/QuantityQ.html}, note=[Accessed: 21-November-2024 ]}