Hyperbolic Tangent of Vector
Create a vector and calculate the hyperbolic tangent of each value.
X = [0 pi 2*pi 3*pi]; Y = tanh(X)
Y = 1×4
0 0.9963 1.0000 1.0000
Graph of Hyperbolic Tangent Function
Plot the hyperbolic tangent function over the domain .
x = -5:0.01:5;
y = tanh(x);
X — Input angles in radians
scalar | vector | matrix | multidimensional array | table | timetable
Input angles in radians, specified as a scalar, vector, matrix, multidimensional array, table, or timetable.
Complex Number Support: Yes
The hyperbolic tangent of an angle x is the ratio of the hyperbolic sine and hyperbolic cosine
In terms of the traditional tangent function with a complex argument, the identity is
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version HistoryIntroduced before R2006a
R2023a: Perform calculations directly on tables and timetables
tanh function can calculate on all variables within a table or
timetable without indexing to access those variables. All variables must have data types
that support the calculation. For more information, see Direct Calculations on Tables and Timetables.