function Tf = tchop(Tf)
%TCHOP  Rounds the simulation horizon Tf to a convenient value 
%       for plotting purposes.

%   Pascal Gahinet, 10-23-96
%   Copyright (c) 1986-97 by The MathWorks, Inc.
% $Revision: 1.4 $

% Define rounding preferences for integers between 11 and 100
pref = [12 12 15 15 15 16 18 18 20 20 ... % 11 to 20
        25 25 25 25 25 30 30 30 30 30 ... % 21 to 30
        32 32 36 36 36 36 40 40 40 40 ... % 31 to 40
        45 45 45 45 45 50 50 50 50 50];   % 41 to 50

% Write z=0.999*Tf as  z=x*10^y with 10<x<=100
z = 0.999*Tf;
y10 = 10^(ceil(log10(z))-2);  % 10^y
x = z/y10;       

% Reset Tf
if x>50, 
   Tf = 10*ceil(x/10)*y10;
else
   Tf = pref(max(1,ceil(x)-10))*y10;
end

% end tchop
