This site uses cookies from Google to deliver and enhance the quality of its services and to analyse traffic.Learn moreOK, got it

Variable in one unit

IDSTAT-31
TitleUse a variable in one unit as much as possible.
PriorityRecommended
Severity level8
DescriptionUse a variable in one unit as much as possible. Use a named constant for converting to another unit if conversion is truly necessary.
RationaleMaintain readability by using the same unit of measure throughout a function.

Avoid:

halfLifeTime = 580; % [s] halfLifeTime = halfLifeTime / 3600; % [h]

Instead use:

SECONDS_TO_HOURS = 1 / 3600; halfLifeTime = 580; % [s] halfLifeTime = halfLifeTime * SECONDS_TO_HOURS; % [h]