Function
This simulation component outputs the result of any given Function
, with an arbitrary number of inputs and variables.
When to use
Use this simulation component when you want to define a function whose variables can be assigned using an arbitrary number of inputs.
How to use
Add this simulation component from the simulation component library.
Define the desired number of inputs to use as variables, choose when the function should be evaluated,
and then define the function.
Parameters
InputFunction
Specifies the function to be calculated.
Supports functions from the System.Math
library.
Examples:
Sqrt(x1)
Sin(x1)
...
EvaluateOn
Determines when to evaluate the given Function
.
Value | Description |
---|---|
After Input Changed | The function is evaluated, when an arbitrary input changes it's value. |
Before Simulation Step | The function is evaluated right before the simulation steps forward in time. |
After Simulation Step | The function is evaluated right after the simulation has stepped forward in time. |
NumberInputs
Indicates the number of variables available for use in your Function
.
Inputs
Inputs are created dynamically according to the defined number of inputs.
InputFunction
Indicates the function you want to calculate.
Outputs
Result
Outputs the result of the given Function
.
Example
In this example, we have two inputs:
- x1 =
4
- x2 =
3.5
The input function is:
Sqrt(Max(x1, x2))
This function calculates the square root of the larger of the two input values. Since x1 (4) is greater than x2 (3.5), the calculation becomes:
Sqrt(4) = 2
The function is evaluated after any input changes, because EvaluateOn
is set to After Input Changed
.
At this point, the Result
is 2.