MATLAB often represents very large or very small numbers using scientific notation, with the letter ‘e‘ separating the significand from the exponent. While convenient for computation, this format can be difficult to interpret for some users. Fortunately, MATLAB provides simple ways to convert these values into more readable decimal formats.
Understanding e-Notation in MATLAB
In scientific notation, a number is expressed as the product of a decimal number between 1 and 10 and a power of 10. For example:
5.2e3 = 5.2 * 10^3 = 5200 1.5e-5 = 1.5 * 10^-5 = 0.000015
The ‘e‘ separates the significand (the digits representing the value) from the exponent. The exponent indicates how many places the decimal point has been shifted from the significand. A positive exponent means the decimal moved right, while a negative exponent means it moved left.
This compact notation allows MATLAB to concisely represent everything from infinitesimally tiny fractions to astronomically huge numbers without loss of precision. However, it can make values harder to grasp at a glance compared to standard decimal form.
Benefits of Converting from e-Notation
While scientific notation serves an important purpose in computations, expanding values into decimal form better serves:
- Displaying statistical data or results
- Preparing datasets for input/export into other programs
- Ensuring appropriate precision for financial calculations
- Making outputs more interpretable for debugging
- Facilitating understanding for beginners first learning MATLAB
Challenges Understanding e-Notation
For MATLAB beginners, several factors can make e-notation confusing:
- Lacking intuition for how the exponent scales the number
- Confusing the notation with math constants like e or π
- Losing sense of data magnitude when exploring intermediate outputs
- Displaying complex numbers where e separates real and imaginary parts
Converting to decimal form helps avoid these issues when readability matters most.
Converting from Scientific Notation in MATLAB
MATLAB provides three numeric formats to remove the ‘e‘ and expand numbers into decimal form:
| Command | Digits | Example Output |
| format long g | 15 significant digits | 5300000000000000000000000000000 |
| format short g | 5 significant digits | 0.0000037 |
| format bank | 2 significant digits | 6e+23 |
To use these, simply apply the formatting command before displaying your number:
big_num = 5.3e124; format long g big_num5300000000000000000000000000000
The updated output reflects our selected format rather than default scientific notation, improving readability.
Choosing Appropriate Formats
The optimal format depends on the use case:
- format long g – Maximizing precision for calculations.
- format short g – Balancing precision and conciseness for debugging.
- format bank – Preparing data for UIs or non-computational use.
In general, avoid conversions that might introduce rounding errors mid-calculation.
Usage Examples
Here are some examples of removing e-notation from scalars and matrices:
Scalar Example – Debugging
tiny_num = 3.7e-16;format short g tiny_num
0.0000037
The short g format expands this tiny number for easy debugging.
Matrix Example – Dataset Export
A = [6.023e23 7.4e-11; 3.7e5 2.998e8];format bank
A6e+23 7e-12 4e+05 3e+08
The bank format compacts this matrix to 2 significant digits, preparing it for CSV export. Trailing zeros are still visible to convey magnitude.
Statistical Data Example – Reporting
net_worth = [1.2e9; 5.1e8; 3.7e8; 1.5e7]; years = 2010:2013;format long g table(years,net_worth)
Year net_worth
2010 120000000000 2011 5100000000 2012 3700000000 2013 15000000The long g format maximizes precision, avoiding rounding financial data during analysis. This data could be prepared for a report.
Comparing to Python Numpy
Like MATLAB, Python‘s Numpy library also prints extremely small or large numbers in scientific notation by default. However, Numpy provides fewer built-in options for formatting outputs. Common approaches include:
- Rounding values using np.round()
- Specifying a formatter on plot ticks
- Handling the string representation manually
MATLAB‘s dedicated numeric formats offer simpler and more powerful control for developers needing to remove e-notation programmatically.
How MATLAB‘s Formatting Functions Work
Under the hood, MATLAB‘s formatting functions use algorithms to:
- Estimate decimal precision needed to display the value to the desired digits
- Handle edge cases like overflow and underflow gracefully
- Manage output display width when expanding values
- Preserve matrix dimensions accurately
By leveraging optimized C and Fortran libraries, these functions provide efficient conversions configurable to the use case.
Conclusion
Converting numbers from scientific notation can greatly improve comprehensibility and interpretability in MATLAB outputs. The format long g, format short g, and format bank commands offer simple yet powerful options tailored to different precision needs. Using these techniques appropriately, developers can fine-tune numeric representations for both human-readable display and fully-precise computation.


