log10
Common logarithm (base 10)
Syntax
Description
Y = log10(
returns
the common logarithm of each element in array X
)X
.
The function accepts both real and complex inputs. For real values
of X
in the interval (0, Inf
), log10
returns
real values in the interval (-Inf
,Inf
).
For complex and negative real values of X
, the log10
function
returns complex values.
Examples
Examine several values of the base 10 logarithm function.
Calculate the common logarithm of 1.
log10(1)
ans = 0
The result is 0
, so this is the x-intercept of the log10
function.
Calculate the common logarithm of 10.
log10(10)
ans = 1
The result is 1
since .
Calculate the common logarithm of 100.
log10(100)
ans = 2
The result is 2
since .
Calculate the common logarithm of 0.
log10(0)
ans = -Inf
The result is -Inf
since .
Create a vector of numbers in the interval [0.5 5]
.
X = (0.5:0.5:5)';
Calculate the common logarithm of X
.
Y = log10(X)
Y = 10×1
-0.3010
0
0.1761
0.3010
0.3979
0.4771
0.5441
0.6021
0.6532
0.6990
Create two Cartesian grids for X
and Y
.
[X,Y] = meshgrid(0:0.5:1.5,-2:0.5:2);
Calculate the complex base 10 logarithm on the grid. Use 1i
for improved speed and robustness with complex arithmetic.
Z = log10(X + 1i*Y)
Z = 9×4 complex
0.3010 - 0.6822i 0.3142 - 0.5758i 0.3495 - 0.4808i 0.3979 - 0.4027i
0.1761 - 0.6822i 0.1990 - 0.5425i 0.2559 - 0.4268i 0.3266 - 0.3411i
0.0000 - 0.6822i 0.0485 - 0.4808i 0.1505 - 0.3411i 0.2559 - 0.2554i
-0.3010 - 0.6822i -0.1505 - 0.3411i 0.0485 - 0.2014i 0.1990 - 0.1397i
-Inf + 0.0000i -0.3010 + 0.0000i 0.0000 + 0.0000i 0.1761 + 0.0000i
-0.3010 + 0.6822i -0.1505 + 0.3411i 0.0485 + 0.2014i 0.1990 + 0.1397i
0.0000 + 0.6822i 0.0485 + 0.4808i 0.1505 + 0.3411i 0.2559 + 0.2554i
0.1761 + 0.6822i 0.1990 + 0.5425i 0.2559 + 0.4268i 0.3266 + 0.3411i
0.3010 + 0.6822i 0.3142 + 0.5758i 0.3495 + 0.4808i 0.3979 + 0.4027i
Input Arguments
Input array, specified as a scalar, vector, matrix, multidimensional array, table, or timetable.
Data Types: single
| double
| table
| timetable
Complex Number Support: Yes
Extended Capabilities
The
log10
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™.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
The log10
function
supports GPU array input with these usage notes and limitations:
If the output of the function running on the GPU can be complex, then you must explicitly specify its input arguments as complex. For more information, see Work with Complex Numbers on a GPU (Parallel Computing Toolbox).
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006aThe log10
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.
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)