Skip to Main Content Skip to Search
Product Documentation

Fcn - Apply specified expression to input

Library

User-Defined Functions

Description

The Fcn block applies the specified mathematical expression to its input. The expression can include one or more of these components:

The Fcn block observes the following rules of operator precedence:

  1. ( )

  2. ^

  3. + - (unary)

  4. !

  5. * /

  6. + -

  7. > < <= >=

  8. == !=

  9. &&

  10. ||

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.

Data Type Support

The Fcn block accepts and outputs signals of type single or double.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

Expression

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).

    Note   You cannot tune this expression during simulation in Normal or Accelerator mode (see How the Acceleration Modes Work), or in generated code.

    The Fcn block does not support custom storage classes. See Custom Storage Classes in the Embedded Coder documentation.

Sample time (-1 for inherited)

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time in the online documentation for more information.

Examples

The following demo models show how to use the Fcn block:

Characteristics

Direct Feedthrough

Yes

Sample Time

Inherited from the driving block

Scalar Expansion

No

Dimensionalized

No

Multidimensionalized

No

Zero-Crossing Detection

No

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS