Trigonometric Function
Specified trigonometric function on input
Libraries:
Simulink /
Math Operations
HDL Coder /
Math Operations
HDL Coder /
HDL Floating Point Operations
Description
The Trigonometric Function block performs common trigonometric functions and outputs the result in rad or rev.
Supported Functions
You can select one of these functions from the Function parameter list.
Function | Description | Mathematical Expression | MATLAB® Equivalent |
---|---|---|---|
sin
| Sine of the input |
|
sin
|
cos
| Cosine of the input |
|
cos
|
tan
| Tangent of the input |
|
tan
|
asin
| Inverse sine of the input |
|
asin
|
acos
| Inverse cosine of the input |
|
acos
|
atan
| Inverse tangent of the input |
|
atan
|
atan2
| Four-quadrant inverse tangent of the input |
|
atan2
|
sinh
| Hyperbolic sine of the input |
|
sinh
|
cosh
| Hyperbolic cosine of the input |
|
cosh
|
tanh
| Hyperbolic tangent of the input |
|
tanh
|
asinh
| Inverse hyperbolic sine of the input |
|
asinh
|
acosh
| Inverse hyperbolic cosine of the input |
|
acosh
|
atanh
| Inverse hyperbolic tangent of the input |
|
atanh
|
sincos
| Sine of the input; cosine of the input | — | — |
cos + jsin
| Complex exponential of the input | — | — |
CORDIC Approximation Method
CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations. For more information, see More About. The block input has further requirements.
For more information on when you set Function to
sin
, cos
, sincos
, or
cos + jsin
and set the Approximation
method to CORDIC
, see Port_1.
This table summarizes what happens for an invalid input.
Block Usage | Effect of Invalid Input |
---|---|
Simulation modes | An error appears. |
Generated code | Undefined behavior occurs. Avoid relying on undefined behavior for generated code. |
Lookup Approximation Method
For more information on when you set Function to
sin
, cos
, sincos
,
or cos + jsin
and set the Approximation method
to Lookup
, see Port_1.
Examples
Limitations
You can use fixed-point input signals only when Approximation method is set to
CORDIC
orLookup
. The CORDIC and Lookup approximations are available for thesin
,cos
,sincos
,cos + jsin
, andatan2
functions.Complex input signals are supported for all functions in this block except
atan2
.When you set Approximation method to
Lookup
, the number of data points are limited by:smallEnoughNumDataPoints = 2(inputFractionLen-2)+1
bigEnoughFractionLen = log2(numberOfDataPoints - 1)+2
where:
smallEnoughNumDataPoints is the maximum number of data points represented by specified input fraction length, inputFractionLen.
bigEnoughFractionLen is the minimum fraction length needed to represent specified number of data points, numberOfDataPoints.
When you set Function to
sin
,cos
,sincos
, orcos + jsin
and set the Approximation method toCORDIC
, the block has these limitations:When you use signed fixed-point types, the input angle must fall within the range [–2π, 2π) rad.
When you use unsigned fixed-point types, the input angle must fall within the range [0, 2π) rad.
When you set Function to
atan2
and the Approximation method toCORDIC
, the block has these limitations:Inputs must be the same size, or at least one value must be a scalar value.
Both inputs must have the same data type.
When you use signed fixed-point types, the word length must be
126
or less.When you use unsigned fixed-point types, the word length must be
125
or less.
When you set Function to
sin
,cos
,sincos
, orcos + jsin
and set the Approximation method toLookup
, the block has these limitations.When you use signed fixed-point types, the input angle must fall within the range [-2π,2π] rad.
When you use unsigned fixed-point types, the input angle must fall within the range [0,2π) rad.
When you set Function to
atan2
and the Approximation method toLookup
, the block has these limitations:Inputs must be the same size, or at least one value must be a scalar value.
Both inputs must have the same data type.
Ports
Input
Output
Parameters
Block Characteristics
More About
References
[1] Volder, Jack E., “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers EC-8 (1959); 330–334.
[2] Andraka, Ray “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): 191–200.
[3] Walther, J.S., “A Unified Algorithm for Elementary Functions,” Proceedings of the Spring Joint Computer Conference, May 18-20, 1971: 379–386.
[4] Schelin, Charles W., “Calculator Function Approximation,” The American Mathematical Monthly 90, no. 5 (1983): 317–325.
Extended Capabilities
Version History
Introduced before R2006a
See Also
Blocks
Functions
cordicsin
(Fixed-Point Designer) |cordiccos
(Fixed-Point Designer) |cordicsincos
(Fixed-Point Designer)