| Contents | Index |
Math Operations
The Trigonometric Function block performs common trigonometric functions. You can select one of the following functions from the Function parameter list.
| Function | Description | Mathematical Expression | MATLAB Equivalent |
|---|---|---|---|
| sin | Sine of the input | sin(u) | sin |
| cos | Cosine of the input | cos(u) | cos |
| tan | Tangent of the input | tan(u) | tan |
| asin | Inverse sine of the input | asin(u) | asin |
| acos | Inverse cosine of the input | acos(u) | acos |
| atan | Inverse tangent of the input | atan(u) | atan |
| atan2 | Four-quadrant inverse tangent of the input | atan2(u) | atan2 |
| sinh | Hyperbolic sine of the input | sinh(u) | sinh |
| cosh | Hyperbolic cosine of the input | cosh(u) | cosh |
| tanh | Hyperbolic tangent of the input | tanh(u) | tanh |
| asinh | Inverse hyperbolic sine of the input | asinh(u) | asinh |
| acosh | Inverse hyperbolic cosine of the input | acosh(u) | acosh |
| atanh | Inverse hyperbolic tangent of the input | atanh(u) | atanh |
| sincos | Sine of the input; cosine of the input | — | — |
| cos + jsin | Complex exponential of the input | — | — |
The block output is the result of applying the function to one or more inputs in radians. Each function supports:
Scalar operations
Element-wise vector and matrix operations
Note Not all compilers support the asinh, acosh, and atanh functions. If you use a compiler that does not support those functions, a warning appears and the generated code fails to link. |
If you select the atan2 function, the block shows two inputs. The first input is the y-axis or imaginary part of the function argument. The second input is the x-axis or real part of the function argument. (See How to Rotate a Block in the Simulink documentation for a description of the port order for various block orientations.)
If you select the sincos function, the block shows two outputs. The first output is the sine of the function argument, and the second output is the cosine of the function argument.
If you use the CORDIC approximation method (see Definitions), the block input has the following restrictions:
For signed fixed-point types, the input angle must fall within the range [–2π, 2π) radians.
For unsigned fixed-point types, the input angle must fall within the range [0, 2π) radians.
The following table summarizes what happens for an out-of-range input.
| Block Usage | Effect of Out-of-Range Input |
|---|---|
| Simulation | An error appears. |
| Generated code | Undefined behavior occurs. |
| Accelerator modes |
Ensure that you use an in-range input for the Trigonometric Function block when you use the CORDIC approximation, which is available for the sin, cos, sincos, and cos + jsin functions. Avoid relying on undefined behavior for generated code or Accelerator modes.
CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is among one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see [1], [2]) The CORDIC algorithm eliminates the need for explicit multipliers. Using CORDIC, you can calculate various functions, such as sine, cosine, arc sine, arc cosine, arc tangent, and vector magnitude. You can also use this algorithm for divide, square root, and hyperbolic, and logarithmic functions.
Increasing the number of CORDIC iterations can produce more accurate results, but doing so also increases the expense of the computation and adds latency.
The block accepts input signals of the following data types:
| Functions | Input Data Types |
|---|---|
|
|
|
|
The block output data type depends on the input data type and your selection for Approximation method:
| Input Data Type | Approximation Method | Output Data Type |
|---|---|---|
Floating point | None or CORDIC | Same as input |
Fixed point | CORDIC | fixdt(1, WL, WL – 2) where WL is the input word length This fixed-point type provides the best precision for the CORDIC algorithm. |
The CORDIC approximation is available for the sin, cos, sincos, and cos + jsin functions.
Complex input signals are supported for all functions in this block, except atan2. The block output is real or complex, depending on your selection for Output signal type. This parameter is not available when you use the CORDIC approximation to compute block output. For CORDIC approximations, the output must be:
Real for sin, cos, and sincos
Complex for cos + jsin

Specify the trigonometric function. The name of the function on the block icon changes to match your selection.
Specify the type of approximation for computing output. This parameter appears only when you set Function to sin, cos, sincos, or cos + jsin.
| Approximation Method | Data Types Supported | When to Use This Method |
|---|---|---|
| None (default) | Floating point | You want to use the default Taylor series algorithm. |
| CORDIC | Floating point and fixed point | You want a fast, approximate calculation. |
If you select CORDIC, the block icon changes:
| Function | Block Icon |
|---|---|
| sin |
|
| cos |
|
| sincos |
|
| cos + jsin |
|
When you use the CORDIC approximation, follow these guidelines:
For signed fixed-point types, the input angle must fall within the range [–2π, 2π) radians.
For unsigned fixed-point types, the input angle must fall within the range [0, 2π) radians.
Specify the number of iterations to perform the CORDIC algorithm. The default value is 11.
When the block input uses a floating-point data type, the number of iterations can be a positive integer.
When the block input is a fixed-point data type, the number of iterations cannot exceed the word length.
For example, if the block input is fixdt(1,16,15), the word length is 16. In this case, the number of iterations cannot exceed 16.
This parameter appears when both of the following conditions hold:
You set Function to sin, cos, sincos, or cos + jsin.
You set Approximation method to CORDIC.
Specify the output signal type of the Trigonometric Function block as auto, real, or complex.
| Function | Input Signal Type | Output Signal Type | ||
|---|---|---|---|---|
| Auto | Real | Complex | ||
| Any selection for the Function parameter | real | real | real | complex |
| complex | complex | error | complex | |
Note When Function is atan2, complex input signals are not supported for simulation or code generation. |
Setting Approximation method to CORDIC disables this parameter.
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 Simulink documentation for more information.
Suppose that you have the following model:

The key block parameters for the Constant block are:
| Parameter | Setting |
|---|---|
| Constant value | 1 |
| Output data type | Inherit: Inherit from 'Constant value' |
The block parameters for the Trigonometric Function block are:
| Parameter | Setting |
|---|---|
| Function | sin |
| Approximation method | None |
| Output signal type | auto |
| Sample time | -1 |
The output type of the Trigonometric Function block is the same as the input because the input type is floating point and Approximation method is None.
Suppose that you have the following model:

The key block parameters for the Constant block are:
| Parameter | Setting |
|---|---|
| Constant value | 1 This value must fall within the range [–2π, 2π) because the Trigonometric Function block uses the CORDIC algorithm and the block input uses a signed fixed-point type. |
| Output data type | fixdt(1,13,5) |
The block parameters for the Trigonometric Function block are:
| Parameter | Setting |
|---|---|
| Function | sincos |
| Approximation method | CORDIC |
| Number of iterations | 11 |
| Sample time | -1 |
The output type of the Trigonometric Function block is fixdt(1,13,11) because the input type is fixed point and Approximation method is CORDIC. The output fraction length equals the input word length – 2.
The following model compares the complex exponential output for the two different approximation methods:

The key block parameters for the Constant blocks are:
| Block | Parameter | Setting |
|---|---|---|
| Constant | Constant value | [-pi/2 0 pi] |
| Output data type | fixdt(1,16,2) | |
| Constant1 | Constant value | [-pi/2 0 pi] |
| Output data type | double |
The block parameters for the Trigonometric Function blocks are:
| Block | Parameter | Setting |
|---|---|---|
| Approximation = 'CORDIC' | Function | cos + jsin |
| Approximation method | CORDIC | |
| Number of iterations | 11 | |
| Sample time | -1 | |
| Approximation = 'None' | Function | cos + jsin |
| Approximation method | None | |
| Sample time | -1 |
When the Approximation method is CORDIC, the input data type can be fixed point, in this case: fixdt(1,16,2). The output data type is fixdt(1,16,14) because the output fraction length equals the input word length – 2.
When the Approximation method is None, the input data type must be floating point. The output data type is the same as the input.
To learn how to generate a digital waveform using a CORDIC sine approximation, see the description for the sldemo_tonegen_fixpt model.
Direct Feedthrough | Yes |
Sample Time | Inherited from the driving block |
Scalar Expansion | Yes, of the input when the function requires two inputs |
Dimensionalized | Yes |
Multidimensionalized | Yes |
Zero-Crossing Detection | No |
[1] Volder, J.E. "The CORDIC Trigonometric Computing Technique," IRE Transactions on Electronic Computers. Vol. EC-8, September 1959, pp. 330–334.
[2] Andraka, R. "A survey of CORDIC algorithm for FPGA based computers." Proceedings of the 1998 ACM/SIGDA sixth international symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp. 191–200.

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 |