A student working in the MATLAB Command Window runs format long, then format compact, then format rat, and finally prints a variable with fprintf('%.3f', x). Which of the following statements about MATLAB numeric display are true? Select all that apply.
After format rat, the assignment x = 0.75 stores x as the exact fraction 3/4 rather than as a double.
The fprintf call prints x with three decimal places no matter which format setting is active.
Running format compact shortens displayed results to fewer digits after the decimal point to save space.
Switching from format short to format long reveals digits already stored; it does not make later calculations more precise.
Unlock full course notes by signing up
Bank format and a later calculation
In the MATLAB Command Window a student runs format bank and then types price = 4.996, and MATLAB displays price = 5.00. Next the student types total = 3*price without changing the format. What does MATLAB display?
Error from retyping a displayed time
In MATLAB with the default format short, a script sets t = 1/3, a duration in hours, and the Command Window shows t = 0.3333. The script converts to seconds with s = t*3600, while a student retypes the displayed value and computes s2 = 0.3333*3600. By how many seconds does s exceed s2? Give your answer in seconds to two decimal places.
Common scale factor in a vector display
An engineer stores a pump's power draw in watts and its efficiency loss in watts in one row vector, then runs these lines in the Command Window:
Because the largest entry is at least 1000, format short prints a common scale factor line of the form 1.0e+0n * above the row, followed by each entry divided by that factor and shown to four decimal places.
Find three things: the power of ten nnn in the scale factor, as an integer; the number displayed for the second entry under that scale factor, exactly as shown to four decimal places; and the number displayed when the engineer next types x(2) on its own, exactly as shown to four decimal places.
Ranking formats by significant digits shown
The double r = 1/7 is displayed in the Command Window under each of the formats listed below. Order the formats from the one that shows the fewest significant digits of r to the one that shows the most. Do not count a leading zero before the decimal point or the digits of an exponent as significant.