%% Rise Time, Reference-Level Instants, and Reference Levels
% Determine the rise 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('transitionex.mat','x','t')

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

[R,lt,ut,ll,ul] = risetime(x,t);

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

plot(t,x)
xlabel('seconds')
ylabel('Volts')

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

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

% Copyright 2015 The MathWorks, Inc.