| Simulink® | ![]() |
Math Operations
The Math Function block performs numerous common mathematical functions.
You can select one of the following functions from the Function parameter list.
| Function | Description | Mathematical Expression | MATLAB Equivalent |
|---|---|---|---|
| exp | Exponential | eu | exp |
| log | Natural logarithm | ln u | log |
| 10^u | Array power of base 10 | 10u | 10.^u |
| log10 | Common (base 10) logarithm | log u | log10 |
| magnitude^2 | Complex modulus | |u|2 | |
| square | Array power 2 | u2 | u.^2 |
| sqrt | Square root | u0.5 | sqrt |
| pow | Array power | uv | power |
| conj | Complex conjugate | ū | conj |
| reciprocal | Array reciprocal | 1/u | 1./u |
| hypot | Square root of sum squares | (u2+v2)0.5 | hypot |
| rem | Remainder after division | — | rem |
| mod | Modulus after division | — | mod |
| transpose | Array transpose | uT | u.' |
| hermitian | Complex conjugate transpose | uH | u' |
The block output is the result of the operation of the function on the input or inputs.
The name of the function appears on the block. Simulink software automatically draws the appropriate number of input ports.
Use the Math Function block instead of the Fcn block when you want vector or matrix output, because the Fcn block produces only scalar output.
The following table shows which input data types are supported by each of the functions of the Math Function block.
| Function | single | double | built-in integer | fixed point |
|---|---|---|---|---|
exp | yes | yes | — | — |
log | yes | yes | — | — |
10^u | yes | yes | — | — |
log10 | yes | yes | — | — |
magnitude^2 | yes | yes | yes | yes |
square | yes | yes | yes | yes |
sqrt | yes | yes | yes | yes |
pow | yes | yes | — | — |
conj | yes | yes | yes | yes |
reciprocal | yes | yes | yes | yes |
hypot | yes | yes | — | — |
rem | yes | yes | yes | — |
mod | yes | yes | yes | — |
transpose | yes | yes | yes | yes |
hermitian | yes | yes | yes | yes |
All supported modes accept both real and complex inputs, except for reciprocal and sqrt, which do not accept complex fixed-point inputs. Also, sqrt does not accept fixed-point inputs that are negative or that have nontrivial slope and nonzero bias. The output signal type of the block is real or complex, depending on the setting of the Output signal type parameter.
The Main pane of the Math Function block dialog appears as follows:

Specify the mathematical function. See Description for more information about the options for this parameter.
Select the output signal type of the Math Function block as real, complex, or auto.
| Input | Output Signal Type | |||
|---|---|---|---|---|
| Function | Signal | Auto | Real | Complex |
exp, log, 10u, log10, square, sqrt, pow, reciprocal, conjugate, transpose, hermitian | real complex | real complex | real error | complex complex |
magnitude squared | real complex | real real | real real | complex complex |
hypot, rem, mod | real complex | real error | real error | complex error |
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.
The Signal Attributes pane of the Math Function block dialog appears as follows:

Note Some of the parameters on this pane are available only when the function chosen in the Function parameter supports fixed-point data types. |
Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Specifying Block Output Data Types for more information.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
If selected, fixed-point overflows saturate.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of the input when the function requires two inputs |
Dimensionalized | Yes |
Multidimensionalized | Yes, for all functions except hermitian and transpose |
Zero Crossing | No |
![]() | Manual Switch | MATLAB Fcn | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |