Main Content

simscape.isCommensurateUnit

Check whether units are commensurate

Since R2021b

Description

c = simscape.isCommensurateUnit(unitlist) checks whether all the arguments in the list have commensurate units. The function returns true if all units are commensurate, false otherwise.

example

Examples

collapse all

Create a simscape.Value object:

 v1 = simscape.Value([100, 200, 300], "cm/s");

Create scalar simscape.Unit objects:

u1 = simscape.Unit("mm/s");
u2 = simscape.Unit("rad/s");

Check whether units of v1 and u1 are commensurate with the unit of meters per second:

 simscape.isCommensurateUnit(v1,u1,"m/s")
ans =

  logical

   1

The function returns true because all the units are commensurate.

Check whether units of all three objects are commensurate:

 simscape.isCommensurateUnit(v1,u1,u2)
ans =

  logical

   0

The function returns false because the unit of u2 is not commensurate with the others.

Input Arguments

collapse all

List of units for comparison, specified as character vectors, strings, scalar simscape.Unit objects, or simscape.Value objects. For simscape.Value objects, the function compares the unit of the object with the other units in the list.

Version History

Introduced in R2021b