The technical computing software MATLAB is used by scientists and engineers for data processing and analysis. Frequently, data contained in arrays and matrices are manipulated using built-in array and matrix functions until the data is represented in the correct form. During algorithm development, calculations are often performed step-by-step in the Command window to see the resulting answer. The standard MATLAB display format rounds the displayed number to four places. Numbers that are longer retain their numerical values to 15 places during the calculation but are still only displayed to four places. It frequently becomes necessary to display all 15 places during the arithmetic depending on the precision of the calculation.
- Skill level:
- Moderately Easy
Other People Are Reading
Clear all active variables in the workspace by entering "Clear all" into the MATLAB "Command" window.
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.
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.
Decrease the amount of digits displayed by entering "format short." Repeating Step 2 outputs "0.3333," the same results as in the second step.
Tips and warnings
- Although MATLAB displays only four digits to the right of the decimal in "format short," MATLAB uses the 15-digit number to perform the calculation. Verify this by first inputting "format short" into the Command window followed by the command "pi." MATLAB outputs "3.1416." Click on the "ans" variable in the Workspace window. The Variable Editor opens with "pi" represented using 15 digits after the decimal.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for