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.

You can call elementary mathematical functions like acos, asin, atan2, cos, cosh, exp, fabs, log, log10, pow, sin, sinh, sqrt, tan, and tanh. For example, if you enter pow (2,3) to the Gain parameter on the gain block, the result is 8.

Embed also interprets pi as the universal constant π.

If you are unfamiliar with the C language and want to learn how to enter mathematical functions in C format, see C: A Software Engineering Approach, (Springer-Verlag, 1990).

Most numeric data can be expressed using the arithmetic operators +  - * / and the usual rules of precedence. For example:

2 * (5 + 4) = 18

2 * 5 + 4 = 14

2 + 5 * 4 = 22

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.