rats returns asterisks for elements that cannot be printed in the allotted space, but which are not negligible compared to the other elements in X.
Create a 4-by-4 matrix.
format short X = hilb(4)
X = 1.0000 0.5000 0.3333 0.2500 0.5000 0.3333 0.2500 0.2000 0.3333 0.2500 0.2000 0.1667 0.2500 0.2000 0.1667 0.1429
View the rational representation of the matrix using rats. The result is the same as using format rat.
R = rats(X)
R = 1 1/2 1/3 1/4 1/2 1/3 1/4 1/5 1/3 1/4 1/5 1/6 1/4 1/5 1/6 1/7
Find the rational representation of pi with the default string length and approximation tolerance. The result is the same as using format rat.
ans = 355/113
Adjust the string length of the output, which also adjusts the approximation tolerance.
ans = 104348/33215
The resulting rational approximation has greater accuracy. As the string length increases, the tolerance decreases.
Adjust the string length again to achieve greater accuracy.
ans = 1146408/364913
The resulting approximation agrees with pi to 10 decimal places.
Input array, specified as a numeric array of class single or double.
Data Types: single | double
Complex Number Support: Yes
String length, specified as a positive integer. The default string length is 13, which allows for 6 elements in 78 spaces.