%% Falltime, Reference-Level Instants, and Reference Levels
% Determine the fall time, reference-level instants, and reference levels in a 2.3 V clock waveform sampled at 4 MHz.
% Load the 2.3 V clock waveform along with the sampling instants.

load('negtransitionex.mat','x','t')

%
% Determine the fall time, reference-level instants, and reference levels.

[f,lt,ut,ll,ul] = falltime(x,t);

%
% Plot the waveform with the upper and lower reference levels and reference level instants. Show that the fall time is the difference between the lower- and upper-reference level instants.

plot(t,x)

xlabel('Seconds')
ylabel('Volts')

hold on
plot([lt ut],[ll ul],'ro')
hold off

fprintf('Rise time is %g seconds.',lt-ut)

% Copyright 2015 The MathWorks, Inc.