How can I print out a zero instead of an asterisk while row-reducing a matrix?
14 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
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
A = [1/1125899906842624, pi, exp(1)]
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)
0 Comments
See Also
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!