MATLAB: Finding start and end points of a sloped plateau

MATLABplateausignal processing

I am analyzing breathing signals, such as below, with varying numbers of plateaus (2-5 per file) and separated by respiratory cycling. I am trying to separate the plateaus. Currently I have just been hand selecting the starting and ending points to run analysis on the plateaus, but does anyone have an idea on how I can automatically select these points?
Plateaus are shown below the yellow arrows, and the points i would like to select are circled in red.
Thank you for any help you can give me.

Best Answer

The islocalmax function or the Find Local Extrema task may be of use to you.