Apply specified expression to input
u — The input to the block.
u is a vector,
ith element of the vector;
represents the first element.
Arithmetic operators (+ -
* / ^).
Relational operators (
== != > < >=
<=) — The expression returns 1 if the relation
is true; otherwise, it returns 0.
Logical operators (&& || !) — The expression returns 1 if the relation is true; otherwise, it returns 0.
sign in MATLAB®),
The Fcn block does not support
Workspace variables — Variable names that are
not recognized in the preceding list of items are passed to MATLAB for
evaluation. Matrix or vector elements must be specifically referenced
A(1,1) instead of
the first element in the matrix).
The Fcn block observes the following rules of operator precedence:
+ - (unary)
> < <= >=
The expression differs from a MATLAB expression in that the expression cannot perform matrix computations. Also, this block does not support the colon operator (:).
Block input can be a scalar or vector. The output is always
a scalar. For vector output, consider using the Math Function block. If a block input
is a vector and the function operates on input elements individually
(for example, the
sin function), the block operates
on only the first vector element.
The Fcn block has the following limitations:
You cannot tune the expression during simulation in Normal or Accelerator mode (see How Acceleration Modes Work), or in generated code. To implement tunable expressions, tune the expression outside the Fcn block. For example, use the Relational Operator block to evaluate the expression outside.
The Fcn block does not support custom storage classes. See Custom Storage Classes (Embedded Coder) in the Embedded Coder® documentation.
The Fcn block accepts and outputs signals of type
For more information, see Data Types Supported by Simulink in the Simulink® documentation.
Specify the mathematical expression to apply to the input. Expression components are listed above. The expression must be mathematically well-formed (uses matched parentheses, proper number of function arguments, and so on). The expression has restrictions on tunability (see Limitations)
This parameter is not visible in the block dialog box unless
it is explicitly set to a value other than
The following example models show how to use the Fcn block:
sldemo_enginewc (Throttle &
Double | Single
Inherited from driving block