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 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.
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.
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.