Main Content

cordictanh

CORDIC-based hyperbolic tangent

Description

example

T= cordictanh(theta)returns the hyperbolic tangent oftheta.

example

T= cordictanh(theta,niters)returns the hyperbolic tangent of theta by performingnitersiterations of the CORDIC algorithm.

Examples

collapse all

Find the hyperbolic tangent offiobjectthetausing 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 ofthetausing thetanhfunction and its CORDIC approximation.

T = tanh(double(theta)); plot(theta, T_cordic); holdon; plot(theta, T); legend('CORDIC approximation of tanh','tanh'); xlabel('theta'); ylabel('tanh(theta)');

图包含一个坐标轴对象。坐标轴对象有限公司ntains 2 objects of type line. These objects represent CORDIC approximation of tanh, tanh.

Compute the difference between the results of thecordictanhfunction and thetanhfunction.

figure; err = abs(T - double(T_cordic)); plot(theta, err); xlabel('theta'); ylabel('error');

图包含一个坐标轴对象。坐标轴对象有限公司ntains an object of type line.

Find the hyperbolic tangent offiobjectthetausing 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);forniters = 5:10:25 T_cordic = cordictanh(theta, niters); plot(theta, T_cordic); holdon;endxlabel('theta'); ylabel('tanh(theta)'); legend('5 iterations','15 iterations','25 iterations','Location','southeast');

图包含一个坐标轴对象。坐标轴对象有限公司ntains 3 objects of type line. These objects represent 5 iterations, 15 iterations, 25 iterations.

Input Arguments

collapse all

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

The number of iterations that the CORDIC algorithm performs, specified as a positive, integer-valued scalar. If you do not specifyniters, the algorithm uses a default value. For fixed-point inputs, the default value ofniters是一个小于len这个词gth of the input array,theta. For double-precision inputs, the default value ofnitersis 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

collapse all

Tis the CORDIC-based approximation of the hyperbolic tangent oftheta. 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 theWordLength2.

Introduced in R2017b