EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab log
 

Matlab log

Updated March 8, 2023

Matlab log

 

 

Introduction to Matlab log

Matlab log method can be used to compute the natural logarithm or common logarithm of any number. It can also be used to compute the natural logarithm or common logarithm of an array of numbers or a matrix of numbers. Please keep in mind that a natural logarithm has “e” as its base, where “e” represents Euler’s number and has a value of 2.71828, and a common logarithm has 10 as its base.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax:

  • A = log (Number) is used to compute the natural logarithm (base “e)” of a number in Matlab. In the case of an array, we will get the natural logarithm of every element in the array.
  • A = log10 (Number) is used to compute the common logarithm (base 10) of a number in Matlab. In the case of an array, we will get the common logarithm of every element in the array.

Examples of Matlab log

Given below shows how to compute the natural logarithm in Matlab using the log method:

Example #1

In this example, we will use the log method to compute the natural logarithm of a number.

The step to be followed for this example is:

  • Pass the number whose natural logarithm is required as an argument to the log method.

Code:

log(4)

[Passing 4 as an argument to the log method as we need its natural logarithm] [Mathematically, the log of 4 to the base “e” is 1.3863]

This is how our input and output will look like in the Matlab command window:

Input:

Matlab log 1

Output:

Matlab log 2

As we can see in the output, we have the log of 4 to the base “e” as 1.3863, which is the same as expected by us.

Example #2

In this example, we will use the log method to compute the natural logarithm of the elements of an array.

The steps to be followed for this example are:

  • Initialize the array.
  • Pass the array as an argument to the log method.

Code:

A = [3 6 4 8 6 1] [Initializing the array whose natural logarithm is to be computed]

log(A)

[Passing the array as an argument to the log method]

This is how our input and output will look like in the Matlab command window:

Input:

Matlab log 3

Output:

matlab log 4

As we can see in the output, we have obtained the log of all the elements in the array to the base “e”, as expected by us.

Example #3

In this example, we will use the log method to compute the natural logarithm of the elements of a matrix.

The steps to be followed for this example are:

  • Initialize the matrix.
  • Pass the matrix as an argument to the log method.

Code:

A = [3 6 4; 8 6 1; 2 1 6] [Initializing the matrix whose natural logarithm is to be computed]

log(A)

[Passing the matrix as an argument to the log method]

This is how our input and output will look like in the Matlab command window:

Input:

matlab log 5

Output:

compute the natural logarithm of the elements of a matrix

As we can see in the output, we have obtained the log of all the elements in the matrix to the base “e”, as expected by us.

In the above 3 examples, we have computed the natural logarithm of numbers using the log method.

Next, we will compute the common logarithm of numbers using the log10 method.

Example #4

In this example, we will use the log10 method to compute the common logarithm of a number.

The step to be followed for this example is:

  • Pass the number whose natural logarithm is required as an argument to the log method.

Code:

log10(5)

[Passing 5 as an argument to the log10 method as we need its common logarithm] [Mathematically, the log of 5 to the base “10” is 0.6990]

This is how our input and output will look like in the Matlab command window:

Input:

matlab log 7

Output:

compute the common logarithm of a number

As we can see in the Output, we have the log of 5 to the base “10” as 0.6990, which is the same as expected by us.

Example #5

In this example, we will use the log10 method to compute the common logarithm of the elements of an array.

The steps to be followed for this example are:

  • Initialize the array.
  • Pass the array as an argument to the log10 method.

Code:

A = [4 7 1 3 6 2] [Initializing the array whose common logarithm is to be computed]

log10(A)

[Passing the array as an argument to the log10 method]

This is how our input and output will look like in the Matlab command window:

Input:

matlab log 9

Output:

we will use the log10 method to compute the common logarithm

As we can see in the output, we have obtained the log of all the elements in the array to the base “10”, as expected by us.

Example #6

In this example, we will use the log10 method to compute the common logarithm of the elements of a matrix.

The steps to be followed for this example are:

  • Initialize the matrix.
  • Pass the matrix as an argument to the log10 method.

Code:

A = [2 5 4; 1 6 3; 6 3 7] [Initializing the matrix whose common logarithm is to be computed]

log10(A)

[Passing the matrix as an argument to the log10 method]

This is how our input and output will look like in the Matlab command window:

Input:

matlab log 11

Output:

compute the common logarithm of the elements of a matrix

As we can see in the output, we have obtained the log of all the elements in the matrix to the base “10”, as expected by us.

Conclusion

The log method can be used in Matlab to compute the logarithm of a number, an array or a matrix. Both natural and common logarithm can be computed. It can be used to compute the logarithm of arrays and matrices as well.

Recommended Articles

This is a guide to the Matlab log. Here we discuss the introduction to Matlab log along with examples for better understanding. You may also have a look at the following articles to learn more –

  1. Matlab Forms
  2. Matlab plot title
  3. Matlab Format
  4. Convolution Matlab

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW