|
|
|
This module is used to include a user defined in-line (math) function in a model.
|
|
|
|
|
|
This module is used to include a user defined in-line (math) function in a
|
|
Usage: The module supports a number of different types of mathematical functions:
|
|
model.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
The module supports a number of different types of mathematical functions:
|
|
|
|
- Polynomials.
|
|
- Polynomials.
|
|
- Non-polynomial combinations of variables and constants.
|
|
- Non-polynomial combinations of variables and constants.
|
|
- Sines and cosines.
|
|
- Sines and cosines.
|
... | @@ -12,44 +10,22 @@ The module supports a number of different types of mathematical functions: |
... | @@ -12,44 +10,22 @@ The module supports a number of different types of mathematical functions: |
|
- Square root.
|
|
- Square root.
|
|
- Combinations of the above.
|
|
- Combinations of the above.
|
|
|
|
|
|
Operation:
|
|
Operation: When using this module, place it in the model window and connect the desired number of input variables via a Mux and one output that will pass on the resulting value from the (user defined) function. Double click on the Fcn icon and enter the desired function in the Expression field. The first (top) input variable to the Mux is defined as 'u\[1\]', the second input variable (from the top) is defined as 'u\[2\]', etc. (please note the square brackets). The user defined function can consist of any combination of terms made up of constants multiplied with variables, sine and/or cosine functions, floating-point absolute values, log10 values, and/or square roots.
|
|
When using this module, place it in the model window and connect the
|
|
|
|
desired number of input variables via a Mux and one output that will pass
|
|
|
|
on the resulting value from the (user defined) function. Double click on
|
|
|
|
the Fcn icon and enter the desired function in the Expression field. The
|
|
|
|
first (top) input variable to the Mux is defined as 'u[1]', the second
|
|
|
|
input variable (from the top) is defined as 'u[2]', etc. (please note the
|
|
|
|
square brackets). The user defined function can consist of any combination
|
|
|
|
of terms made up of constants multiplied with variables, sine and/or cosine
|
|
|
|
functions, floating-point absolute values, log10 values, and/or square
|
|
|
|
roots.
|
|
|
|
|
|
|
|
Once the function has been defined, click on OK and the function will be
|
|
|
|
incorporated into the model. Please note that it is up to the user to
|
|
|
|
ensure the validity of entered functions and values, e.g., only positive
|
|
|
|
values for logarithms, no negative values for square roots, no divisions by
|
|
|
|
zero, etc. Also, sine and cosine values should, by default, be given in
|
|
|
|
radians. If angles in degrees are desired, replace 'sin' with 'sindeg' and
|
|
|
|
'cos' with 'cosdeg'.
|
|
|
|
|
|
|
|
In order to include polynomials, a special technique must be used. This is
|
|
|
|
best explained with an example. Let's assume the following polynomial
|
|
|
|
should be used:
|
|
|
|
|
|
|
|
|
|
Once the function has been defined, click on OK and the function will be incorporated into the model. Please note that it is up to the user to ensure the validity of entered functions and values, e.g., only positive values for logarithms, no negative values for square roots, no divisions by zero, etc. Also, sine and cosine values should, by default, be given in radians. If angles in degrees are desired, replace 'sin' with 'sindeg' and 'cos' with 'cosdeg'.
|
|
|
|
|
|
|
|
In order to include polynomials, a special technique must be used. This is best explained with an example. Let's assume the following polynomial should be used:
|
|
|
|
|
|
|
|
```
|
|
Out = 2.0 * In1 + 3.5 * In2 ** 2 + 5.0 * In3 ** 3
|
|
Out = 2.0 * In1 + 3.5 * In2 ** 2 + 5.0 * In3 ** 3
|
|
|
|
```
|
|
|
|
|
|
This would require a Mux with six inputs. In other words, the first input
|
|
This would require a Mux with six inputs. In other words, the first input variable ('In1') is connected to the first input to the Mux ('u\[1\]'), the second input variable ('In2') is connected to the second and third inputs to the Mux (and will be referred to as 'u\[2\]' and 'u\[3\]' in the function expression), and the third input variable ('In3') is connected to the fourth, fifth, and sixth inputs to the Mux (referred to as 'u\[4\]', 'u\[5\]', and 'u\[6\]', respectively).
|
|
variable ('In1') is connected to the first input to the Mux ('u[1]'), the
|
|
|
|
second input variable ('In2') is connected to the second and third inputs
|
|
|
|
to the Mux (and will be referred to as 'u[2]' and 'u[3]' in the function
|
|
|
|
expression), and the third input variable ('In3') is connected to the
|
|
|
|
fourth, fifth, and sixth inputs to the Mux (referred to as 'u[4]', 'u[5]',
|
|
|
|
and 'u[6]', respectively).
|
|
|
|
|
|
|
|
## Examples
|
|
## Examples
|
|
|
|
|
|
### Cosine
|
|
### Cosine
|
|
Block layout:
|
|
|
|

|
|
Block layout: 
|
|
Example Expression:
|
|
|
|
 |
|
Example Expression:  |
|
\ No newline at end of file |
|
\ No newline at end of file |