Matlab

How to Remove e in MATLAB?

When we deal with very large and very small numbers in MATLAB, it returns the number in the form of scientific notation (format e) which becomes difficult for users to understand the scientific notation or to approximate the decimal value of the given number. To handle this problem, MATLAB facilitates us with some formats to convert a scientific notation into decimal notation.

This blog will walk through the way to remove exponentials e from a scalar or a matrix in MATLAB.

What is e in MATLAB?

In MATLAB, the symbol e is used to represent scientific notation. Scientific notation is the way of converting a very small and very large decimal number into a simple form by expressing the number as a product of a decimal number between 0 and 10 with the powers of 10.

Note: Don’t confuse the symbol e with the exp() function.

How to Remove e in MATLAB?

Sometimes MATLAB returns very small and very large values in the form of scientific notation which becomes difficult for users who are not familiar with the scientific notation. To handle this problem, MATLAB allows us to convert scientific notation into a decimal format using:

  • format long g
  • format short g
  • format bank

Syntax

All the above formats use an easy syntax that is given below:

format long g
format short g
format bank

Here,

format long g: It formats the value by a total of fifteen significant digits.

format short g: It formats the values by a total of five significant digits.

format bank: It formats the value by a total of two significant digits.

Examples

Consider some examples to understand how to remove e in MATLAB.

Example 1: How to Remove e From a Scalar Value in MATLAB?

In this example, we use the format long g to remove e from the given number and convert the number into the decimal format.

num =1.2e+12
format long g
num

Example 2: How to Remove e From a Matrix in MATLAB?

This example removes e from the given matrix and converts it into the decimal format using the format bank.

A =1e+6*rand(3)
format bank
A

Conclusion

Whenever MATLAB returns a scalar or a matrix in scientific notation, it becomes difficult for users who aren’t familiar with scientific notation. So, we can convert a value from scientific notation to decimal using the format short g, format long g, and format bank commands. This tutorial has presented the process in a simple way by removing e from a scalar or a matrix in MATLAB.

About the author

Komal Batool Batool

I am passionate to research technologies and new ideas and that has brought me here to write for the LinuxHint. My major focus is to write on programming languages and computer science related topics.