%% Adjust Output Vector Length
% Find the rational representation of pi with the default character vector length and approximation tolerance. The result is the same as using format rat.

rats(pi)

%
% Adjust the length of the output, which also adjusts the approximation tolerance.

rats(pi,20)

% The resulting rational approximation has greater accuracy. As the output length increases, the tolerance decreases.
%
% Adjust the output length again to achieve greater accuracy.

rats(pi,25)

% The resulting approximation agrees with pi to 10 decimal places.
% Copyright 2012 The MathWorks, Inc.