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
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
, 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 .
Real-Valued Common Logarithm
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
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 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
X
— Input array
scalar | vector | matrix | multidimensional array | table | timetable
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
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
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™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
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).
Distributed Arrays
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 History
Introduced before R2006aR2023a: Perform calculations directly on tables and timetables
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.
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)