log10

Common logarithm (base 10)

Syntax

Description

example

Y = log10(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

expand all

Calculate Scalar Common Logarithm Values

Examine several values of the base 10 logarithm function.

Calculate the common logarithm of 1.

log10(1)
ans =

       0

The result is 0, which is the x-intercept of the log10 function.

Calculate the common logarithm of 10.

log10(10)
ans =

       1

The result is 1 since 10^1 = 10.

Calculate the common logarithm of 100.

log10(100)
ans =

     2

The result is 2 since 10^2 = 100.

Calculate the common logarithm of 0.

log10(0)
ans =

  -Inf

The result is -Inf since 10^(-Inf) = 0.

Real-Valued Common Logarithm

Create a vector of real numbers in the interval [0.5,10].

X = (0.5:0.5:10)';

Calculate the common logarithm of X.

Y = log10(X)
Y =

   -0.3010
         0
    0.1761
    0.3010
    0.3979
    0.4771
    0.5441
    0.6021
    0.6532
    0.6990
    0.7404
    0.7782
    0.8129
    0.8451
    0.8751
    0.9031
    0.9294
    0.9542
    0.9777
    1.0000

Complex-Valued Common Logarithm

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 $log_{10}(X + iY)$ on the grid. Use 1i for improved speed and robustness with complex arithmetic.

Z = log10(X + 1i*Y)
Z =

   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

expand all

X — Input arrayscalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: single | double
Complex Number Support: Yes

See Also

| | | | | | | |

Was this topic helpful?