Technology computers-hardware

How to Format Decimal Places in MATLAB

    • 1). Clear all active variables in the workspace by entering "Clear all" into the MATLAB "Command" window.

    • 2). Create a number that has an unlimited amount of digits to the right of the decimal place. The fraction "1/3" has the number "3" repeated after the decimal to infinity, so input "1/3" into the "Command" window. MATLAB outputs "0.3333" with four digits shown to the right of the decimal.

    • 3). Increase the amount of digits displayed. Enter "format long" into the Command window. Repeat Step 2 and input "1/3" into the "Command" window. MATLAB now outputs "0.333333333333333," which displays fifteen digits to the right of the decimal.

    • 4). Decrease the amount of digits displayed by entering "format short." Repeating Step 2 outputs "0.3333," the same results as in the second step.

Leave a reply