cordictanh
CORDIC-based hyperbolic tangent
Description
Examples
Compute CORDIC Hyperbolic Tangent
Find the hyperbolic tangent of fi
object theta
using a CORDIC implementation with the default number of iterations.
theta = fi(-2*pi:.1:2*pi-.1); T_cordic = cordictanh(theta);
Plot the hyperbolic tangent of theta
using the tanh
function and its CORDIC approximation.
T = tanh(double(theta)); plot(theta, T_cordic); hold on; plot(theta, T); legend('CORDIC approximation of tanh', 'tanh'); xlabel('theta'); ylabel('tanh(theta)');
Compute the difference between the results of the cordictanh
function and the tanh
function.
figure; err = abs(T - double(T_cordic)); plot(theta, err); xlabel('theta'); ylabel('error');
Compute CORDIC Hyperbolic Tangent with Specified Number of Iterations
Find the hyperbolic tangent of fi
object theta
using a CORDIC implementation and specify the number of iterations the CORDIC kernel should perform. Plot the CORDIC approximation of the hyperbolic tangent of theta with varying numbers of iterations.
theta = fi(-2*pi:.1:2*pi-.1); for niters = 5:10:25 T_cordic = cordictanh(theta,niters); plot(theta,T_cordic); hold on; end xlabel('theta'); ylabel('tanh(theta)'); legend('5 iterations','15 iterations',... '25 iterations','Location','southeast');
Input Arguments
theta
— angle values
scalar | vector | matrix | n-dimensional array
Angle values in radians specified as a scalar, vector, matrix, or N-dimensional array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
niters
— Number of iterations
scalar
The number of iterations that the CORDIC algorithm performs, specified as
a positive, integer-valued scalar. If you do not specify
niters
, the algorithm uses a default value. For
fixed-point inputs, the default value of niters
is one
less than the word length of the input array, theta
.
For double-precision inputs, the default value of niters
is 52. For single-precision inputs, the default value is 23.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Output Arguments
T
— Output array
scalar | vector | matrix | n-dimensional array
T
is the CORDIC-based approximation of the hyperbolic
tangent of theta
. When the input to the function is
floating point, the output data type is the same as the input data type.
When the input is fixed point, the output has the same word length as the
input, and a fraction length equal to the WordLength
–
2
.
Extended Capabilities
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
The cordictanh
function also supports MATLAB® to High-Level Synthesis (HLS) code generation.
Version History
Introduced in R2017b
See Also
cordicatan2
| cordicsin
| cordiccos
| tanh
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)