Name | Description |
---|---|
![]() | Return the arithmetic mean of numbers |
![]() | Return the harmonic mean of numbers |
Example:
average({1,2,3})
returns 2.
Type | Name | Default | Description |
---|---|---|---|
Real | u[:] | Vector of numbers |
Type | Name | Description |
---|---|---|
Real | mean | Arithmetic mean |
function arithmetic "Return the arithmetic mean of numbers" extends Modelica.Icons.Function; input Real u[:] "Vector of numbers"; output Real mean "Arithmetic mean"; algorithm mean := sum(u)/size(u, 1); end arithmetic;
Example:
average({1,2,3})
returns 2.
Type | Name | Default | Description |
---|---|---|---|
Real | u[:] | Vector of numbers |
Type | Name | Description |
---|---|---|
Real | mean | Harmonic mean |
function harmonic "Return the harmonic mean of numbers" extends Modelica.Icons.Function; input Real u[:] "Vector of numbers"; output Real mean "Harmonic mean"; // TODO: Add check to FCSysTest. algorithm mean := if size(u, 1) == 1 then u[1] else (if size(u, 1) == 2 then 2*product( u)/sum(u) else size(u, 1)/sum(1/u for u in u)); end harmonic;