## Modelica.Blocks.Math

Library of Real mathematical functions as input/output blocks

### Information

This package contains basic mathematical operations, such as summation and multiplication, and basic mathematical functions, such as sqrt and sin, as input/output blocks. All blocks of this library can be either connected with continuous blocks or with sampled-data blocks.

Extends from Modelica.Icons.Package (Icon for standard packages).

### Package Content

NameDescription
UnitConversions Conversion blocks to convert between SI and non-SI unit signals
InverseBlockConstraints Construct inverse model by requiring that two inputs and two outputs are identical (replaces the previously, unbalanced, TwoInputs and TwoOutputs blocks)
Gain Output the product of a gain value with the input signal
MatrixGain Output the product of a gain matrix with the input signal vector
MultiSum Sum of Reals: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]
MultiProduct Product of Reals: y = u[1]*u[2]* ... *u[n]
MultiSwitch Set Real expression that is associated with the first active input signal
Sum Output the sum of the elements of the input vector
Feedback Output difference between commanded and feedback input
Add Output the sum of the two inputs (this is an obsolet block. Use instead MultiSum)
Add3 Output the sum of the three inputs (this is an obsolet block. Use instead MultiSum)
Product Output product of the two inputs (this is an obsolet block. Use instead MultiProduct)
Division Output first input divided by second input
Abs Output the absolute value of the input
Sign Output the sign of the input
Sqrt Output the square root of the input (input >= 0 required)
Sin Output the sine of the input
Cos Output the cosine of the input
Tan Output the tangent of the input
Asin Output the arc sine of the input
Acos Output the arc cosine of the input
Atan Output the arc tangent of the input
Atan2 Output atan(u1/u2) of the inputs u1 and u2
Sinh Output the hyperbolic sine of the input
Cosh Output the hyperbolic cosine of the input
Tanh Output the hyperbolic tangent of the input
Exp Output the exponential (base e) of the input
Log Output the natural (base e) logarithm of the input (input > 0 required)
Log10 Output the base 10 logarithm of the input (input > 0 required)
RealToInteger Convert Real to Integer signal
IntegerToReal Convert integer to real signals
BooleanToReal Convert Boolean to Real signal
BooleanToInteger Convert Boolean to Integer signal
RealToBoolean Convert Real to Boolean signal
IntegerToBoolean Convert Integer to Boolean signal
RectangularToPolar Convert rectangular coordinates to polar coordinates
PolarToRectangular Convert polar coordinates to rectangular coordinates
Mean Calculate mean over period 1/f
RectifiedMean Calculate refctified mean over period 1/f
RootMeanSquare Calculate root mean square over period 1/f
Harmonic Calculate harmonic over period 1/f
Max Pass through the largest signal
Min Pass through the smallest signal
Edge Indicates rising edge of boolean signal
BooleanChange Indicates boolean signal changing
IntegerChange Indicates integer signal changing

## Modelica.Blocks.Math.InverseBlockConstraints

Construct inverse model by requiring that two inputs and two outputs are identical (replaces the previously, unbalanced, TwoInputs and TwoOutputs blocks)

### Information

Exchange input and ouput signals of a block, i.e., the previous block inputs become block outputs and the previous block outputs become block inputs. This block is used to construct inverse models. Its usage is demonstrated in example: Modelica.Blocks.Examples.InverseModel.

Note, if a block shall be inverted that has several input and output blocks, then this can be easily achieved by using a vector of InverseBlockConstraints instances:

```   InverseBlockConstraint invert[3];  // Block to be inverted has 3 input signals
```

### Connectors

TypeNameDescription
input RealInputu1Input signal 1 (u1 = u2)
input RealInputu2Input signal 2 (u1 = u2)
output RealOutputy1Output signal 1 (y1 = y2)
output RealOutputy2Output signal 2 (y2 = y2)

### Modelica definition

```block InverseBlockConstraints
"Construct inverse model by requiring that two inputs and two outputs are identical (replaces the previously, unbalanced, TwoInputs and TwoOutputs blocks)"

Modelica.Blocks.Interfaces.RealInput u1 "Input signal 1 (u1 = u2)";
Modelica.Blocks.Interfaces.RealInput u2 "Input signal 2 (u1 = u2)";
Modelica.Blocks.Interfaces.RealOutput y1 "Output signal 1 (y1 = y2)";
Modelica.Blocks.Interfaces.RealOutput y2 "Output signal 2 (y2 = y2)";

equation
u1 = u2;
y1 = y2;
end InverseBlockConstraints;
```

## Modelica.Blocks.Math.Gain

Output the product of a gain value with the input signal

### Information

This block computes output y as product of gain k with the input u:

```    y = k * u;
```

### Parameters

TypeNameDefaultDescription
Realk Gain value multiplied with input signal [1]

### Connectors

TypeNameDescription
input RealInputuInput signal connector
output RealOutputyOutput signal connector

### Modelica definition

```block Gain "Output the product of a gain value with the input signal"

parameter Real k(start=1, unit="1") "Gain value multiplied with input signal";
public
Interfaces.RealInput u "Input signal connector";
Interfaces.RealOutput y "Output signal connector";

equation
y = k*u;
end Gain;
```

## Modelica.Blocks.Math.MatrixGain

Output the product of a gain matrix with the input signal vector

### Information

This blocks computes output vector y as product of the gain matrix K with the input signal vector u:

```    y = K * u;
```

Example:

```   parameter: K = [0.12 2; 3 1.5]

results in the following equations:

| y[1] |     | 0.12  2.00 |   | u[1] |
|      |  =  |            | * |      |
| y[2] |     | 3.00  1.50 |   | u[2] |
```

Extends from Interfaces.MIMO (Multiple Input Multiple Output continuous control block).

### Parameters

TypeNameDefaultDescription
RealK[:, :][1, 0; 0, 1]Gain matrix which is multiplied with the input
Integerninsize(K, 2)Number of inputs
Integernoutsize(K, 1)Number of outputs

### Connectors

TypeNameDescription
input RealInputu[nin]Connector of Real input signals
output RealOutputy[nout]Connector of Real output signals

### Modelica definition

```block MatrixGain
"Output the product of a gain matrix with the input signal vector"

parameter Real K[:, :]=[1, 0; 0, 1]
"Gain matrix which is multiplied with the input";
extends Interfaces.MIMO(final nin=size(K, 2), final nout=size(K, 1));
equation
y = K*u;
end MatrixGain;
```

## Modelica.Blocks.Math.MultiSum

Sum of Reals: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]

### Information

This blocks computes the scalar Real output "y" as sum of the elements of the Real input signal vector u:

```y = k[1]*u[1] + k[2]*u[2] + ... k[N]*u[N];
```

The input connector is a vector of Real input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.RealNetwork1.

If no connection to the input connector "u" is present, the output is set to zero: y=0.

Extends from Modelica.Blocks.Interfaces.PartialRealMISO (Partial block with a RealVectorInput and a RealOutput signal).

### Parameters

TypeNameDefaultDescription
Realk[nu]fill(1, nu)Input gains
IntegersignificantDigits3Number of significant digits to be shown in dynamic diagram layer for y

### Connectors

TypeNameDescription
input RealVectorInputu[nu]
output RealOutputy

### Modelica definition

```block MultiSum
"Sum of Reals: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]"
extends Modelica.Blocks.Interfaces.PartialRealMISO;
parameter Real k[nu] = fill(1,nu) "Input gains";
equation
if size(u,1) > 0 then
y = k*u;
else
y = 0;
end if;

end MultiSum;
```

## Modelica.Blocks.Math.MultiProduct

Product of Reals: y = u[1]*u[2]* ... *u[n]

### Information

This blocks computes the scalar Real output "y" as product of the elements of the Real input signal vector u:

```y = u[1]*u[2]* ... *u[N];
```

The input connector is a vector of Real input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.RealNetwork1.

If no connection to the input connector "u" is present, the output is set to zero: y=0.

Extends from Modelica.Blocks.Interfaces.PartialRealMISO (Partial block with a RealVectorInput and a RealOutput signal).

### Parameters

TypeNameDefaultDescription
IntegersignificantDigits3Number of significant digits to be shown in dynamic diagram layer for y

### Connectors

TypeNameDescription
input RealVectorInputu[nu]
output RealOutputy

### Modelica definition

```block MultiProduct "Product of Reals: y = u[1]*u[2]* ... *u[n]"
extends Modelica.Blocks.Interfaces.PartialRealMISO;
equation
if size(u,1) > 0 then
y = product(u);
else
y = 0;
end if;

end MultiProduct;
```

## Modelica.Blocks.Math.MultiSwitch

Set Real expression that is associated with the first active input signal

### Information

This block has a vector of Boolean input signals u[nu] and a vector of (time varying) Real expressions expr[nu]. The output signal y is set to expr[i], if i is the first element in the input vector u that is true. If all input signals are false, y is set to parameter "y_default".

```  // Conceptual equation (not valid Modelica)
i = 'first element of u[:] that is true';
y = if i==0 then y_default else expr[i];
```

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.RealNetwork1.

### Parameters

TypeNameDefaultDescription
Realexpr[nu]fill(0.0, nu)y = if u[i] then expr[i] else y_default (time varying)
Realy_default0.0Default value of output y if all u[i] = false
Integerprecision3Number of significant digits to be shown in dynamic diagram layer for y

### Connectors

TypeNameDescription
input BooleanVectorInputu[nu]Set y = expr[i], if u[i] = true
output RealOutputyOutput depending on expression

### Modelica definition

```block MultiSwitch
"Set Real expression that is associated with the first active input signal"

input Real expr[nu]=fill(0.0, nu)
"y = if u[i] then expr[i] else y_default (time varying)";
parameter Real y_default=0.0
"Default value of output y if all u[i] = false";

parameter Integer nu(min=0) = 0 "Number of input connections";
parameter Integer precision(min=0) = 3
"Number of significant digits to be shown in dynamic diagram layer for y";

Modelica.Blocks.Interfaces.BooleanVectorInput u[nu]
"Set y = expr[i], if u[i] = true";
Modelica.Blocks.Interfaces.RealOutput y(start=y_default,fixed=true)
"Output depending on expression";

protected
Integer firstActiveIndex;
initial equation
pre(u) = fill(false,nu);
equation
firstActiveIndex = Modelica.Math.BooleanVectors.firstTrueIndex(
u);
y = if firstActiveIndex == 0 then y_default else expr[firstActiveIndex];
end MultiSwitch;
```

## Modelica.Blocks.Math.Sum

Output the sum of the elements of the input vector

### Information

This blocks computes output y as sum of the elements of the input signal vector u:

```    y = u[1] + u[2] + ...;
```

Example:

```     parameter:   nin = 3;

results in the following equations:

y = u[1] + u[2] + u[3];
```

Extends from Interfaces.MISO (Multiple Input Single Output continuous control block).

### Parameters

TypeNameDefaultDescription
Integernin1Number of inputs
Realk[nin]ones(nin)Optional: sum coefficients

### Connectors

TypeNameDescription
input RealInputu[nin]Connector of Real input signals
output RealOutputyConnector of Real output signal

### Modelica definition

```block Sum "Output the sum of the elements of the input vector"
extends Interfaces.MISO;
parameter Real k[nin]=ones(nin) "Optional: sum coefficients";
equation
y = k*u;
end Sum;
```

## Modelica.Blocks.Math.Feedback

Output difference between commanded and feedback input

### Information

This blocks computes output y as difference of the commanded input u1 and the feedback input u2:

```    y = u1 - u2;
```

Example:

```     parameter:   n = 2

results in the following equations:

y = u1 - u2
```

### Connectors

TypeNameDescription
input RealInputu1
input RealInputu2
output RealOutputy

### Modelica definition

```block Feedback
"Output difference between commanded and feedback input"

input Interfaces.RealInput u1;
input Interfaces.RealInput u2;
output Interfaces.RealOutput y;

equation
y = u1 - u2;
end Feedback;
```

Output the sum of the two inputs (this is an obsolet block. Use instead MultiSum)

### Information

This blocks computes output y as sum of the two input signals u1 and u2:

```    y = k1*u1 + k2*u2;
```

Example:

```     parameter:   k1= +2, k2= -3

results in the following equations:

y = 2 * u1 - 3 * u2
```

Extends from Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

### Parameters

TypeNameDefaultDescription
Realk1+1Gain of upper input
Realk2+1Gain of lower input

### Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

### Modelica definition

```block Add
"Output the sum of the two inputs (this is an obsolet block. Use instead MultiSum)"
extends Interfaces.SI2SO;
parameter Real k1=+1 "Gain of upper input";
parameter Real k2=+1 "Gain of lower input";

equation
y = k1*u1 + k2*u2;
```

Output the sum of the three inputs (this is an obsolet block. Use instead MultiSum)

### Information

This blocks computes output y as sum of the three input signals u1, u2 and u3:

```    y = k1*u1 + k2*u2 + k3*u3;
```

Example:

```     parameter:   k1= +2, k2= -3, k3=1;

results in the following equations:

y = 2 * u1 - 3 * u2 + u3;
```

Extends from Interfaces.BlockIcon (Basic graphical layout of input/output block).

### Parameters

TypeNameDefaultDescription
Realk1+1Gain of upper input
Realk2+1Gain of middle input
Realk3+1Gain of lower input

### Connectors

TypeNameDescription
input RealInputu1Connector 1 of Real input signals
input RealInputu2Connector 2 of Real input signals
input RealInputu3Connector 3 of Real input signals
output RealOutputyConnector of Real output signals

### Modelica definition

```block Add3
"Output the sum of the three inputs (this is an obsolet block. Use instead MultiSum)"
extends Interfaces.BlockIcon;

parameter Real k1=+1 "Gain of upper input";
parameter Real k2=+1 "Gain of middle input";
parameter Real k3=+1 "Gain of lower input";
input Interfaces.RealInput u1 "Connector 1 of Real input signals";
input Interfaces.RealInput u2 "Connector 2 of Real input signals";
input Interfaces.RealInput u3 "Connector 3 of Real input signals";
output Interfaces.RealOutput y "Connector of Real output signals";

equation
y = k1*u1 + k2*u2 + k3*u3;
```

## Modelica.Blocks.Math.Product

Output product of the two inputs (this is an obsolet block. Use instead MultiProduct)

### Information

This blocks computes the output y (element-wise) as product of the corresponding elements of the two inputs u1 and u2:

```    y = u1 * u2;
```

Extends from Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

### Modelica definition

```block Product
"Output product of the two inputs (this is an obsolet block. Use instead MultiProduct)"
extends Interfaces.SI2SO;

equation
y = u1*u2;
end Product;
```

## Modelica.Blocks.Math.Division

Output first input divided by second input

### Information

This block computes the output y (element-wise) by dividing the corresponding elements of the two inputs u1 and u2:

```    y = u1 / u2;
```

Extends from Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

### Modelica definition

```block Division "Output first input divided by second input"
extends Interfaces.SI2SO;

equation
y = u1/u2;
end Division;
```

## Modelica.Blocks.Math.Abs

Output the absolute value of the input

### Information

This blocks computes the output y as absolute value of the input u:

```    y = abs( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Abs "Output the absolute value of the input"
extends Interfaces.SISO;
equation
y = abs(u);
end Abs;
```

## Modelica.Blocks.Math.Sign

Output the sign of the input

### Information

This blocks computes the output y as sign of the input u:

```         1  if u > 0
y =  0  if u == 0
-1  if u < 0
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Sign "Output the sign of the input"
extends Interfaces.SISO;
equation
y = sign(u);
end Sign;
```

## Modelica.Blocks.Math.Sqrt

Output the square root of the input (input >= 0 required)

### Information

This blocks computes the output y as square root of the input u:

```    y = sqrt( u );
```

All elements of the input vector shall be zero or positive. Otherwise an error occurs.

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Sqrt
"Output the square root of the input (input >= 0 required)"
extends Interfaces.SISO;

equation
y = sqrt(u);
end Sqrt;
```

## Modelica.Blocks.Math.Sin

Output the sine of the input

### Information

This blocks computes the output y as sine of the input u:

```    y = sin( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Sin "Output the sine of the input"
extends Interfaces.SISO;
equation
y = Modelica.Math.sin(u);
end Sin;
```

## Modelica.Blocks.Math.Cos

Output the cosine of the input

### Information

This blocks computes the output y as cos of the input u:

```    y = cos( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Cos "Output the cosine of the input"
extends Interfaces.SISO;

equation
y = Modelica.Math.cos(u);
end Cos;
```

## Modelica.Blocks.Math.Tan

Output the tangent of the input

### Information

This blocks computes the output y as tan of the input u:

```    y = tan( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Tan "Output the tangent of the input"
extends Interfaces.SISO;

equation
y = Modelica.Math.tan(u);
end Tan;
```

## Modelica.Blocks.Math.Asin

Output the arc sine of the input

### Information

This blocks computes the output y as the sine-inverse of the input u:

```    y = asin( u );
```

The absolute values of the elements of the input u need to be less or equal to one (abs( u ) <= 1). Otherwise an error occurs.

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Asin "Output the arc sine of the input"
extends Interfaces.SISO;

equation
y = Modelica.Math.asin(u);
end Asin;
```

## Modelica.Blocks.Math.Acos

Output the arc cosine of the input

### Information

This blocks computes the output y as the cosine-inverse of the input u:

```    y = acos( u );
```

The absolute values of the elements of the input u need to be less or equal to one (abs( u ) <= 1). Otherwise an error occurs.

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Acos "Output the arc cosine of the input"
extends Interfaces.SISO;
equation
y = Modelica.Math.acos(u);
end Acos;
```

## Modelica.Blocks.Math.Atan

Output the arc tangent of the input

### Information

This blocks computes the output y as the tangent-inverse of the input u:

```    y= atan( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Atan "Output the arc tangent of the input"
extends Interfaces.SISO;
equation
y = Modelica.Math.atan(u);
end Atan;
```

## Modelica.Blocks.Math.Atan2

Output atan(u1/u2) of the inputs u1 and u2

### Information

This blocks computes the output y as the tangent-inverse of the input u1 divided by input u2:

```    y = atan2( u1, u2 );
```

u1 and u2 shall not be zero at the same time instant. Atan2 uses the sign of u1 and u2 in order to construct the solution in the range -180 deg ≤ y ≤ 180 deg, whereas block Atan gives a solution in the range -90 deg ≤ y ≤ 90 deg.

Extends from Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

### Modelica definition

```block Atan2 "Output atan(u1/u2) of the inputs u1 and u2"
extends Interfaces.SI2SO;
equation
y = Modelica.Math.atan2(u1, u2);
end Atan2;
```

## Modelica.Blocks.Math.Sinh

Output the hyperbolic sine of the input

### Information

This blocks computes the output y as the hyperbolic sine of the input u:

```    y = sinh( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Sinh "Output the hyperbolic sine of the input"
extends Interfaces.SISO;

equation
y = Modelica.Math.sinh(u);
end Sinh;
```

## Modelica.Blocks.Math.Cosh

Output the hyperbolic cosine of the input

### Information

This blocks computes the output y as the hyperbolic cosine of the input u:

```    y = cosh( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Cosh "Output the hyperbolic cosine of the input"
extends Interfaces.SISO;
equation
y = Modelica.Math.cosh(u);
end Cosh;
```

## Modelica.Blocks.Math.Tanh

Output the hyperbolic tangent of the input

### Information

This blocks computes the output y as the hyperbolic tangent of the input u:

```    y = tanh( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Tanh "Output the hyperbolic tangent of the input"
extends Interfaces.SISO;
equation
y = Modelica.Math.tanh(u);
end Tanh;
```

## Modelica.Blocks.Math.Exp

Output the exponential (base e) of the input

### Information

This blocks computes the output y as the exponential (of base e) of the input u:

```    y = exp( u );
```

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Exp "Output the exponential (base e) of the input"
extends Interfaces.SISO;

equation
y = Modelica.Math.exp(u);
end Exp;
```

## Modelica.Blocks.Math.Log

Output the natural (base e) logarithm of the input (input > 0 required)

### Information

This blocks computes the output y as the natural (base e) logarithm of the input u:

```    y = log( u );
```

An error occurs if the elements of the input u are zero or negative.

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Log
"Output the natural (base e) logarithm of the input (input > 0 required)"

extends Interfaces.SISO;
equation
y = Modelica.Math.log(u);
end Log;
```

## Modelica.Blocks.Math.Log10

Output the base 10 logarithm of the input (input > 0 required)

### Information

This blocks computes the output y as the base 10 logarithm of the input u:

```    y = log10( u );
```

An error occurs if the elements of the input u are zero or negative.

Extends from Interfaces.SISO (Single Input Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Log10
"Output the base 10 logarithm of the input (input > 0 required)"

extends Interfaces.SISO;
equation
y = Modelica.Math.log10(u);
end Log10;
```

## Modelica.Blocks.Math.RealToInteger

Convert Real to Integer signal

### Information

This block computes the output y as nearest integer value of the input u:

```    y = integer( floor( u + 0.5 ) )  for  u > 0;
y = integer( ceil ( u - 0.5 ) )  for  u < 0;
```

Extends from Interfaces.IntegerBlockIcon (Basic graphical layout of Integer block).

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output IntegerOutputyConnector of Integer output signal

### Modelica definition

```block RealToInteger "Convert Real to Integer signal"
extends Interfaces.IntegerBlockIcon;
public
Interfaces.RealInput u "Connector of Real input signal";
Interfaces.IntegerOutput y "Connector of Integer output signal";
equation
y = if (u > 0) then integer(floor(u + 0.5)) else
integer(ceil( u - 0.5));
end RealToInteger;
```

## Modelica.Blocks.Math.IntegerToReal

Convert integer to real signals

### Information

This block computes the output y as Real equivalent of the Integer input u:

```    y = u;
```

where u is of Integer and y of Real type.

Extends from Interfaces.BlockIcon (Basic graphical layout of input/output block).

### Connectors

TypeNameDescription
input IntegerInputuConnector of Integer input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block IntegerToReal "Convert integer to real signals"
extends Interfaces.BlockIcon;
Interfaces.IntegerInput u "Connector of Integer input signal";
Interfaces.RealOutput y "Connector of Real output signal";
equation
y = u;
end IntegerToReal;
```

## Modelica.Blocks.Math.BooleanToReal

Convert Boolean to Real signal

### Information

This block computes the output y as Real equivalent of the Boolean input u:

```    y = if u then realTrue else realFalse;
```

where u is of Boolean and y of Real type, and realTrue and realFalse are parameters.

Extends from Interfaces.partialBooleanSI (Partial block with 1 input Boolean signal).

### Parameters

TypeNameDefaultDescription
RealrealTrue1.0Output signal for true Boolean input
RealrealFalse0.0Output signal for false Boolean input

### Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block BooleanToReal "Convert Boolean to Real signal"
extends Interfaces.partialBooleanSI;
parameter Real realTrue=1.0 "Output signal for true Boolean input";
parameter Real realFalse=0.0 "Output signal for false Boolean input";

Blocks.Interfaces.RealOutput y "Connector of Real output signal";

equation
y = if u then realTrue else realFalse;
end BooleanToReal;
```

## Modelica.Blocks.Math.BooleanToInteger

Convert Boolean to Integer signal

### Information

This block computes the output y as Integer equivalent of the Boolean input u:

```    y = if u then integerTrue else integerFalse;
```

where u is of Boolean and y of Integer type, and integerTrue and integerFalse are parameters.

Extends from Interfaces.partialBooleanSI (Partial block with 1 input Boolean signal).

### Parameters

TypeNameDefaultDescription
IntegerintegerTrue1Output signal for true Boolean input
IntegerintegerFalse0Output signal for false Boolean input

### Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output IntegerOutputyConnector of Integer output signal

### Modelica definition

```block BooleanToInteger "Convert Boolean to Integer signal"
extends Interfaces.partialBooleanSI;
parameter Integer integerTrue=1 "Output signal for true Boolean input";
parameter Integer integerFalse=0 "Output signal for false Boolean input";

Blocks.Interfaces.IntegerOutput y "Connector of Integer output signal";

equation
y = if u then integerTrue else integerFalse;
end BooleanToInteger;
```

## Modelica.Blocks.Math.RealToBoolean

Convert Real to Boolean signal

### Information

This block computes the Boolean output y from the Real input u by the equation:

```    y = u ≥ threshold;
```

where threshold is a parameter.

Extends from Interfaces.partialBooleanSO (Partial block with 1 output Boolean signal).

### Parameters

TypeNameDefaultDescription
Realthreshold0.5Output signal y is true, if input u >= threshold

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output BooleanOutputyConnector of Boolean output signal

### Modelica definition

```block RealToBoolean "Convert Real to Boolean signal"

Blocks.Interfaces.RealInput u "Connector of Real input signal";
extends Interfaces.partialBooleanSO;
parameter Real threshold=0.5
"Output signal y is true, if input u >= threshold";

equation
y = u >= threshold;
end RealToBoolean;
```

## Modelica.Blocks.Math.IntegerToBoolean

Convert Integer to Boolean signal

### Information

This block computes the Boolean output y from the Integer input u by the equation:

```    y = u ≥ threshold;
```

where threshold is a parameter.

Extends from Interfaces.partialBooleanSO (Partial block with 1 output Boolean signal).

### Parameters

TypeNameDefaultDescription
Integerthreshold1Output signal y is true, if input u >= threshold

### Connectors

TypeNameDescription
input IntegerInputuConnector of Integer input signal
output BooleanOutputyConnector of Boolean output signal

### Modelica definition

```block IntegerToBoolean "Convert Integer to Boolean signal"

Blocks.Interfaces.IntegerInput u "Connector of Integer input signal";
extends Interfaces.partialBooleanSO;
parameter Integer threshold=1
"Output signal y is true, if input u >= threshold";

equation
y = u >= threshold;
end IntegerToBoolean;
```

## Modelica.Blocks.Math.RectangularToPolar

Convert rectangular coordinates to polar coordinates

### Information

The input values of this block are the rectangular components `u_re` and `u_im` of a phasor in two dimensions. This block calculates the length `y_abs` and the angle `y_arg` of the polar representation of this phasor.

```  y_abs = abs(u_re + j*u_im) = sqrt( u_re2 + u_im2 )
y_arg = arg(u_re + j*u_im) = atan2(u_im, u_re)
```

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

### Connectors

TypeNameDescription
input RealInputu_reReal part of rectangular representation
input RealInputu_imImaginary part of rectangular representation
output RealOutputy_absLength of polar representation
output RealOutputy_argAngle of polar representation

### Modelica definition

```block RectangularToPolar
"Convert rectangular coordinates to polar coordinates"
extends Modelica.Blocks.Interfaces.BlockIcon;
Modelica.Blocks.Interfaces.RealInput u_re
"Real part of rectangular representation";
Modelica.Blocks.Interfaces.RealInput u_im
"Imaginary part of rectangular representation";
Modelica.Blocks.Interfaces.RealOutput y_abs "Length of polar representation";
Modelica.Blocks.Interfaces.RealOutput y_arg "Angle of polar representation";

equation
y_abs = sqrt(u_re*u_re + u_im*u_im);
y_arg = Modelica.Math.atan2(u_im, u_re);
end RectangularToPolar;
```

## Modelica.Blocks.Math.PolarToRectangular

Convert polar coordinates to rectangular coordinates

### Information

The input values of this block are the polar components `uabs` and `uarg` of a phasor. This block calculates the components `y_re` and `y_im` of the rectangular representation of this phasor.

```   y_re = u_abs * cos( u_arg )
y_im = u_abs * sin( u_arg )
```

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

### Connectors

TypeNameDescription
input RealInputu_absLength of polar representation
input RealInputu_argAngle of polar representation
output RealOutputy_reReal part of rectangular representation
output RealOutputy_imImaginary part of rectangular representation

### Modelica definition

```block PolarToRectangular
"Convert polar coordinates to rectangular coordinates"
extends Modelica.Blocks.Interfaces.BlockIcon;
Modelica.Blocks.Interfaces.RealInput u_abs "Length of polar representation";
Modelica.Blocks.Interfaces.RealInput u_arg "Angle of polar representation";
Modelica.Blocks.Interfaces.RealOutput y_re
"Real part of rectangular representation";
Modelica.Blocks.Interfaces.RealOutput y_im
"Imaginary part of rectangular representation";

equation
y_re = u_abs * Modelica.Math.cos(u_arg);
y_im = u_abs * Modelica.Math.sin(u_arg);
end PolarToRectangular;
```

## Modelica.Blocks.Math.Mean

Calculate mean over period 1/f

### Information

This block calculates the mean of the input signal u over the given period 1/f:

```1 T
- ∫ u(t) dt
T 0
```

Note: The output is updated after each period defined by 1/f.

Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).

### Parameters

TypeNameDefaultDescription
Frequencyf Base frequency [Hz]

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block Mean "Calculate mean over period 1/f"
extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f(start=50) "Base frequency";
protected
discrete Modelica.SIunits.Time t0 "Start time of simulation";
Real x(start=0) "Integrator state";
equation
when initial() then
t0 = time;
end when;
der(x) = u;
when sample(t0+1/f, 1/f) then
y=f*x;
reinit(x, 0);
end when;
end Mean;
```

## Modelica.Blocks.Math.RectifiedMean

Calculate refctified mean over period 1/f

### Information

This block calculates the rectified mean of the input signal u over the given period 1/f, using the mean block.

Note: The output is updated after each period defined by 1/f.

Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).

### Parameters

TypeNameDefaultDescription
Frequencyf Base frequency [Hz]

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block RectifiedMean "Calculate refctified mean over period 1/f"
extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f(start=50) "Base frequency";
Mean mean(final f=f);
Blocks.Math.Abs abs1;
equation
connect(u, abs1.u);
connect(abs1.y, mean.u);
connect(mean.y, y);
end RectifiedMean;
```

## Modelica.Blocks.Math.RootMeanSquare

Calculate root mean square over period 1/f

### Information

This block calculates the root mean square of the input signal u over the given period 1/f, using the mean block.

Note: The output is updated after each period defined by 1/f.

Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).

### Parameters

TypeNameDefaultDescription
Frequencyf Base frequency [Hz]

### Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

### Modelica definition

```block RootMeanSquare "Calculate root mean square over period 1/f"
extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f(start=50) "Base frequency";
Blocks.Math.Product product;
Mean mean(final f=f);
Blocks.Math.Sqrt sqrt1;
equation

connect(u, product.u1);
connect(u, product.u2);
connect(product.y, mean.u);
connect(mean.y, sqrt1.u);
connect(sqrt1.y, y);
end RootMeanSquare;
```

## Modelica.Blocks.Math.Harmonic

Calculate harmonic over period 1/f

### Information

This block calculates the root mean square and the phase angle of a single harmonic k of the input signal u over the given period 1/f, using the mean block.

Note: The output is updated after each period defined by 1/f.

Note: The harmonic is defined by `√2 rms cos(k 2 π f t - arg)`

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

### Parameters

TypeNameDefaultDescription
Frequencyf Base frequency [Hz]
Integerk Order of harmonic

### Connectors

TypeNameDescription
input RealInputu
output RealOutputy_rmsRoot mean square of polar representation
output RealOutputy_argAngle of polar representation

### Modelica definition

```block Harmonic "Calculate harmonic over period 1/f"
extends Modelica.Blocks.Interfaces.BlockIcon;
parameter Modelica.SIunits.Frequency f(start=50) "Base frequency";
parameter Integer k(start=1) "Order of harmonic";
Blocks.Sources.Sine sin1(
final amplitude=sqrt(2),
final phase=Modelica.Constants.pi/2,
final freqHz=k*f);
Blocks.Sources.Sine sin2(                final amplitude=sqrt(2),
final phase=0,
final freqHz=k*f);
Blocks.Math.Product product1;
Blocks.Math.Product product2;
Mean mean1(final f=f);
Mean mean2(final f=f);
Blocks.Interfaces.RealInput u;
Blocks.Interfaces.RealOutput y_rms "Root mean square of polar representation";
Blocks.Interfaces.RealOutput y_arg "Angle of polar representation";
Blocks.Math.RectangularToPolar rectangularToPolar;
equation

connect(sin2.y, product2.u2);
connect(sin1.y, product1.u1);
connect(u, product1.u2);
connect(u, product2.u1);
connect(product2.y, mean2.u);
connect(product1.y, mean1.u);
connect(mean1.y, rectangularToPolar.u_re);
connect(mean2.y, rectangularToPolar.u_im);
connect(rectangularToPolar.y_abs, y_rms);
connect(rectangularToPolar.y_arg, y_arg);
end Harmonic;
```

## Modelica.Blocks.Math.Max

Pass through the largest signal

### Information

This block computes the output y as maximum of the two Real inputs u1 and u2:

```    y = max ( u1 , u2 );
```

Extends from Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

### Modelica definition

```block Max "Pass through the largest signal"
extends Interfaces.SI2SO;
equation
y = max(u1, u2);
end Max;
```

## Modelica.Blocks.Math.Min

Pass through the smallest signal

### Information

This block computes the output y as minimum of the two Real inputs u1 and u2:

```    y = min ( u1 , u2 );
```

Extends from Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

### Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

### Modelica definition

```block Min "Pass through the smallest signal"
extends Interfaces.SI2SO;
equation
y = min(u1, u2);
end Min;
```

## Modelica.Blocks.Math.Edge

Indicates rising edge of boolean signal

### Information

This block sets the Boolean output y to true, when the Boolean input u shows a rising edge:

```    y = edge( u );
```

Extends from Interfaces.BooleanSISO (Single Input Single Output control block with signals of type Boolean).

### Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

### Modelica definition

```block Edge "Indicates rising edge of boolean signal"
extends Interfaces.BooleanSISO;
equation
y = edge(u);
end Edge;
```

## Modelica.Blocks.Math.BooleanChange

Indicates boolean signal changing

### Information

This block sets the Boolean output y to true, when the Boolean input u shows a rising or falling edge, i.e., when the signal changes:

```    y = change( u );
```

Extends from Interfaces.BooleanSISO (Single Input Single Output control block with signals of type Boolean).

### Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

### Modelica definition

```block BooleanChange "Indicates boolean signal changing"
extends Interfaces.BooleanSISO;
equation
y = change(u);
end BooleanChange;
```

## Modelica.Blocks.Math.IntegerChange

Indicates integer signal changing

### Information

This block sets the Boolean output y to true, when the Integer input u changes:

```    y = change( u );
```

Extends from Interfaces.IntegerSIBooleanSO (Integer Input Boolean Output continuous control block).

### Connectors

TypeNameDescription
input IntegerInputuConnector of Integer input signal
output BooleanOutputyConnector of Boolean output signal

### Modelica definition

```block IntegerChange "Indicates integer signal changing"
extends Interfaces.IntegerSIBooleanSO;
equation
y = change(u);
end IntegerChange;
```

Automatically generated Fri Nov 12 16:27:38 2010.