# How can I print out a zero instead of an asterisk while row-reducing a matrix?

1 view (last 30 days)
Aditi Sekar on 12 Jun 2021
Edited: Adam Danz on 15 Jun 2021
A = [
1 2 1 1 13
0 1 2/3 1 9
0 0 1 15/8 123/8
0 0 * 1 5 ]
I used format rat at the top to try to get all the decimals into fractions but then instead of printing 0 it put an asterisk. Does anyone know a way to still get everything into fractions and keep the 0 in the last row?

Adam Danz on 12 Jun 2021
As explained by the MathWorks Support Team in this answer, an asterisk indicates that the fraction is too long to display. The first example below is the same value as the first element of the second example but it appears as an asterisk in the second example because the results are too long to display.
format rat
1/1125899906842624
ans =
1/1125899906842624
A = [1/1125899906842624, pi, exp(1)]
A =
* 355/113 1457/536
Solution: You can round the values to a number of decimal places that meet your precision needs. Below I round them to 6dp.
A = round(A, 6)
A =
0 355/113 1457/536