function InterpMethod = utSelectInterp(u)
% Infers appropriate interpolation rule from data.

%   Author(s): P. Gahinet
%   Copyright 1986-2011 The MathWorks, Inc.
dthresh = 0.75;    % threshold for discontinuity detection

% Estimate if continuous-time signal is smooth or jumpy
% After normalizing amplitude, declare the input smooth if the max.
% variation per sample does not exceeds DTHRESH% of amplitude range
range = max(real(u))-min(real(u)) + max(imag(u))-min(imag(u));
du = abs(diff(u,[],1));
if ~isempty(du) && all(max(du)<=dthresh*range),
   InterpMethod = 'foh';
else
   InterpMethod = 'zoh';
end
