%% Specify State Levels for Bilevel Waveform
% Specify the state levels for the bilevel waveform instead of estimating the levels from the data. Use the 'StateLevels' name-value pair to enter the low-state level as 0 and the high-state level as 5.

load('pulseex.mat', 'x', 't')
fs = 4e6;
[w,initcross,finalcross] = pulsewidth(x,fs,'StateLevels',[0 5]);

%
% Plot the result annotated with the transition occurrences.

pulsewidth(x,fs,'StateLevels',[0 5]);
ax = gca;
ax.XTick = [initcross finalcross];

% Copyright 2012 The MathWorks, Inc.