Update Fcn authored by Ezekiel Dohmen's avatar Ezekiel Dohmen
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.
- Polynomials.
Usage: - Non-polynomial combinations of variables and constants.
The module supports a number of different types of mathematical functions: - Sines and cosines.
- Polynomials. - Floating-point absolute values.
- Non-polynomial combinations of variables and constants. - log10.
- Sines and cosines. - Square root.
- Floating-point absolute values. - Combinations of the above.
- log10.
- Square root. 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.
- Combinations of the above.
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'.
Operation:
When using this module, place it in the model window and connect the 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:
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 Out = 2.0 * In1 + 3.5 * In2 ** 2 + 5.0 * In3 ** 3
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 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).
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:
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
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:
![image](uploads/bc8bf44145169fc090f7e250a474bb35/image.png) Block layout: ![image](uploads/bc8bf44145169fc090f7e250a474bb35/image.png)
Example Expression:
![image](uploads/26e582998f05b464b3a93df6ec6068db/image.png) Example Expression: ![image](uploads/26e582998f05b464b3a93df6ec6068db/image.png)
\ No newline at end of file \ No newline at end of file