rat
Rational fraction approximation.
📝Syntax
[N, D] = rat(X)
[N, D] = rat(X, tol)
S = rat(X)
S = rat(X, tol)
📥Input Arguments
Parameter Description
X Input array: real or complex, scalar, vector or matrix (single or double).
tol Tolerance: scalar. The default is 1e-6 * norm(X(:), 1).
📤Output Arguments
Parameter Description
N Numerator: array of the same size as X, or the continued fraction character array when a single output is requested.
D Denominator: array of the same size as X.
📄Description

[N, D] = rat(X) returns two integer arrays so that N ./ D is close to X in the sense that abs(N ./ D - X) <= tol.

The rational approximations are generated by truncating continued fraction expansions.

S = rat(X) returns the continued fraction representation as a character array.

💡Examples
[N, D] = rat(pi)
S = rat(pi)
🔗See Also
ratsformat
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub