log10 - Common logarithm (base 10) - MATLAB (original) (raw)
Main Content
Common logarithm (base 10)
Syntax
Description
Y = log10([X](#bua6cre-1-X))
returns the common logarithm of each element in array 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.
The result is 0
, so this is the x-intercept of the log10
function.
Calculate the common logarithm of 10.
The result is 1
since 101=10.
Calculate the common logarithm of 100.
The result is 2
since 102=100.
Calculate the common logarithm of 0.
The result is -Inf
since 10-∞=0.
Create a vector of numbers in the interval [0.5 5]
.
Calculate the common logarithm of 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 log10(X+iY) on the grid. Use 1i
for improved speed and robustness with complex arithmetic.
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
Thelog10
function fully supports tall arrays. For more information, see Tall Arrays.
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).
Version History
Introduced before R2006a
The 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.