Fcn
Apply specified expression to input
Libraries:
Simulink /
UserDefined Functions
Description
The Fcn block applies the specified mathematical expression to its input. The expression can include one or more of these components:
u
— The input to the block. Ifu
is a vector,u(i)
represents the ithe element of the vector;u(1)
oru
alone represents the first element.Numeric constants.
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.
Parentheses.
Mathematical functions —
abs
,acos
,asin
,atan
,atan2
,ceil
,cos
,cosh
,exp
,floor
,hypot
,log
,log10
,power
,rem
,sgn
(equivalent tosign
in MATLAB^{®}),sin
,sinh
,sqrt
,tan
, andtanh
.Note
The Fcn block does not support
round
andfix
. Use the Rounding Function block to apply these rounding modes.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. For example, use
A(1,1)
instead ofA
for the first element in the matrix.
The Fcn block observes these 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.
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 Organize Parameter Data into a Structure by Using Struct Storage Class (Embedded Coder).
Ports
Input
Output
Parameters
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

Extended Capabilities
Version History
Introduced before R2006aSee Also
MATLAB System  MATLAB Function  Interpreted MATLAB Function