| by Arround The Web | No comments

How to Find Common Logarithm (base 10) in MATLAB Using log10

In mathematics, there are two types of logarithms, one is a common logarithm and the other is a natural logarithm. The common logarithm has base 10 while the natural logarithm has base e where the symbol (e) represents Euler’s number. The common logarithm is the inverse of the power function having the base 10 and can be computed easily through the built-in log10() function in MATLAB.

This article will explore the functionality of the log10() function in MATLAB including its syntax, examples and why it is useful to calculate in your programming.

Why Do We Need to Common Logarithm?

Common logarithm (base 10) is useful for solving a variety of mathematical problems and is effective in analyzing data and identifying trends. They are extremely useful in creating visualization plots, such as histograms and bar charts. These types of visualization are widely used for communicating data and trends to others in an effective way.

How to Find Common Logarithm in MATLAB Using the log10() Function?

MATLAB enables us to compute the common logarithm of a scalar, a matrix, or a multidirectional array using the built-in log10() function. This function accepts a variable containing a scalar value, a matrix, or a multidirectional array of real or complex values in the domain [0, inf] and returns their computed common logarithm in the range [-inf, inf] in their respective data type.

Syntax

In MATLAB, we can use the log10() function in the following way:

Y = log10(X)

 
Here,

The function Y = log10(X) calculates the common logarithm of X.

    • If X represents a scalar value, this function returns a scalar value Y which is the common logarithm of X.
    • If X represents a vector, this function returns a vector Y which is the common logarithm of X.
    • If X represents a matrix, this function returns a matrix Y which is the common logarithm of X.
    • If X represents a multidirectional array, this function returns a multidirectional array Y which is the common logarithm of X.

Examples

Consider some examples to practically understand the working of the log10() function in MATLAB.

Example 1: How to Compute the Common Logarithm of a Real-Valued Scalar, Vector, Matrix, and a Multidirectional Array
Using the log10(X) Function?

This example computes the common logarithm of the given real-valued scalar, vector, matrix, and multidirectional array using the log10(X) function in MATLAB.

num = 7.9;
vect = randi(50,1,10);
A = magic(3);
X = randi(50,2,4,2);
log10_num= log10(num)
log10_vect=log10(vect)
log10_A=log10(A)
log10_X=log10(X)

 

 

Example 2: How to Compute the Common Logarithm of a Complex-Valued Scalar, Vector, Matrix, and a Multidirectional Array
Using the log10(X) Function?

In this MATLAB code, we compute the common logarithm of the given complex-valued scalar, vector, and matrix using the log10(X) function in MATLAB.

num = 1-7.9i;
vect = [1 i 0.2+9i];
A = [i 0 7; 0 1 9i; 1 i 0];
log10_num= log10(num)
log10_vect=log10(vect)
log10_A=log10(A)

 

Conclusion

A common logarithm is a mathematical term that has base 10 and is used for solving exponential equations as well as for simplifying calculations having powers of 10. We can compute the common logarithm of any real or complex scalar, matrix, or multidirectional array having the domain [0,inf] using the log10() function in MATLAB. This tutorial has described the basics of using the log10() function by providing syntax and examples for real demonstration in MATLAB.

Share Button

Source: linuxhint.com

Leave a Reply