Perform mathematical function
Math Operations
The Math Function block performs numerous common mathematical functions.
Tip To perform square root calculations, use the Sqrt block. 
You can select one of the following functions from the Function parameter list.
Function  Description  Mathematical Expression  MATLAB^{®} Equivalent 

exp  Exponential 
 exp 
log  Natural logarithm 
 log 
10^u  Power of base 10 


log10  Common (base 10) logarithm 
 log10 
magnitude^2  Complex modulus 
 
square  Power 2 


pow  Power 
 power 
conj  Complex conjugate 
 conj 
reciprocal  Reciprocal 


hypot  Square root of sum squares 
 hypot 
rem  Remainder after division  —  rem 
mod  Modulus after division  —  mod 
transpose  Transpose 


hermitian  Complex conjugate transpose 


The block output is the result of the operation of the function on the input or inputs. The functions support the following types of operations.
Function  Scalar Operations  ElementWise Vector and Matrix Operations  Vector and Matrix Operations 

exp  yes  yes  — 
log  yes  yes  — 
10^u  yes  yes  — 
log10  yes  yes  — 
magnitude^2  yes  yes  — 
square  yes  yes  — 
pow  yes  yes  — 
conj  yes  yes  — 
reciprocal  yes  yes  — 
hypot  yes, on two inputs  yes, on two inputs (two vectors or two matrices of the same size, a scalar and a vector, or a scalar and a matrix)  — 
rem  yes, on two inputs  yes, on two inputs (two vectors or two matrices of the same size, a scalar and a vector, or a scalar and a matrix)  — 
mod  yes, on two inputs  yes, on two inputs (two vectors or two matrices of the same size, a scalar and a vector, or a scalar and a matrix)  — 
transpose  yes  —  yes 
hermitian  yes  —  yes 
The name of the function appears on the block. The appropriate number of input ports appears automatically.
Tip 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 the input data types that each function of the block can support.
Function  single  double  boolean  builtin integer  fixed point 

 yes  yes  —  —  — 
 yes  yes  —  —  — 
 yes  yes  —  —  — 
 yes  yes  —  —  — 
 yes  yes  —  yes  yes 
 yes  yes  —  yes  yes 
 yes  yes  —  —  — 
 yes  yes  —  yes  yes 
 yes  yes  —  yes  yes 
 yes  yes  —  —  — 
 yes  yes  —  yes  — 
 yes  yes  —  yes  — 
 yes  yes  yes  yes  yes 
 yes  yes  —  yes  yes 
All supported modes accept both real and complex inputs, except
for reciprocal
, which does not accept complex fixedpoint
inputs.
The block output is real or complex, depending on what you select for Output signal type.
The Main pane of the Math Function block dialog box appears as follows:
Specify the mathematical function. See Description for more information about the options for this parameter.
Specify the output signal type of the Math Function block as auto
, real
,
or complex
.
Function  Input Signal Type  Output Signal Type  

Auto  Real  Complex  















Note:
This parameter is not visible in the block dialog box unless
it is explicitly set to a value other than 
The Signal Attributes pane of the Math Function block dialog box appears as follows:
Note Some parameters on this pane are available only when the function you select in the Function parameter supports fixedpoint data types. 
Specify the minimum value that the block can output. The default
value is []
(unspecified). Simulink^{®} software
uses this value to perform:
Simulation range checking (see Signal Ranges)
Automatic scaling of fixedpoint data types
Specify the maximum value that the block can output. The default
value is []
(unspecified). Simulink software
uses this value to perform:
Simulation range checking (see Signal Ranges)
Automatic scaling of fixedpoint 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 builtin 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, fixdt(1,16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.
See Control Signal Data Types for more information.
Select to lock the output data type setting of this block against changes by the FixedPoint Tool and the FixedPoint Advisor. For more information, see Use Lock Output Data Type Setting.
Specify the rounding mode for fixedpoint operations. For more information, see Rounding. in the FixedPoint Designer™ documentation.
Action  Reasons for Taking This Action  What Happens for Overflows  Example 

Select this check box.  Your model has possible overflow, and you want explicit saturation protection in the generated code.  Overflows saturate to either the minimum or maximum value that the data type can represent.  The maximum value that the 
Do not select this check box.  You want to optimize efficiency of your generated code. You want to avoid overspecifying how a block handles outofrange signals. For more information, see Checking for Signal Range Errors.  Overflows wrap to the appropriate value that is representable by the data type.  The maximum value that the 
When you select this check box, saturation applies to every internal operation on the block, not just the output or result. Usually, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
Direct Feedthrough  Yes 
Sample Time  Inherited from driving block 
Scalar Expansion  Yes, of the input when the function requires two inputs 
Dimensionalized  Yes 
Multidimensionalized  Yes, for all functions except 
ZeroCrossing Detection  No 