Entering C expressions

C expressions can be used for parameter values. Blocks that allow an expression as a parameter are evaluated only once at the start of the simulation (T=0) and will be entered as a constant for code generation. To evaluate an expression at each time step, use the expression block.

Mathematical functions

Mathematical functions — like acos, asin, atan2, cos, cosh, exp, log, log10, pow, sin, sinh, sqrt, tan, and tanh — can be used for parameter values. For example:

The product of the input value 3 and the Gain value 23 is shown in the display block.

For information on entering mathematical functions in C format, see C: A Software Engineering Approach, (Springer-Verlag, 1990).

Treatment of bitwise XOR operator

In a C expression, a bitwise XOR operator is denoted as a  ^. For example:

$1 expands to the input value 2, and Embed produces the bitwise XOR of 2 and 3, which is 1.

Treatment of constants

Embed treats numeric constants a bit differently than standard C: constants with no decimal point are still considered to be floating-point numbers.

Embed interprets pi as the universal constant π.