Do you have the Image Processing Toolbox? If so, it's two lines of code
measurements = regionprops(logical(yourSignal), 'Area');
allLengths = [measurements.Area]; % Durations (x-widths) of all the peaks.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!