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

9 Ansichten (letzte 30 Tage)
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?

Antworten (1)

Adam Danz
Adam Danz am 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

Kategorien

Mehr zu Sparse Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by