How to Display Two Decimal Places in MATLAB

Written by erin moseley
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Display Two Decimal Places in MATLAB
MATLAB can display your data the way you want it. ( Images)

Mathwork's MATLAB software is predominantly used by scientists and engineers because it offers internal arithmetic at 16-decimal digit, floating point precision. Data can be displayed using the long form, up to a 15-decimal digit display, or the default format, which uses only 5 decimal digits. However, if you still feel the need to shorten your output even further, you can truncate it to two decimal places. The internal computations will still occur at the IEEE floating point precision level no matter which display mode you choose.

Skill level:

Other People Are Reading


  1. 1

    Open the MATLAB program by clicking the appropriate icon used in your computing and operating system environment. Refer to product guides for the specific version of MATLAB for your computing platform, or ask your system administrator about paths or shortcuts to it.

  2. 2

    Use the "Clear" command before running programs or typing commands on the Command screen. Ensure that memory is cleared of values and formats so that computations don't yield confusing or unexpected results.

  3. 3

    Write and then run a program that will make use of functions and computations to generate your data. Include formatting notation, such as "format bank," that will limit the number of decimal places to two. Display your output variables in two-decimal format.

  4. 4

    Type individual commands in the Command window that will manipulate data and output it in the desired format. Define variables and issue format statements prior to making any computations. You'll need to first instruct the MATLAB program that you want to generate truncated output to the screen. Use "format bank" to indicate that you want results displayed to two decimal places.

  5. 5

    Use MATLAB as a calculator to generate output in the desired format. Input data for the computations in the Command window and view the output on the same screen. Use the format command "format bank" to display data that is truncated to two decimal places.

Tips and warnings

  • Computations in MATLAB are done using the appropriate floating-point or native integer precision values.
  • Short forms for displaying values do not decrease the computational level of precision, but will only truncate the final calculated value according to the output display rules.
  • Save MATLAB programs with a file extension of .m, or they won't execute at run time.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.