MATLAB: Digitization of noisy signal

noisy signal digitization

I have a signal as shown in the image here. I am trying to digitize the signal so that it catches the right jump only. My system is jumping between two states with noise. I want to calculate how much time it stays up and how much down. Could you please bring a super cool idea? Thanks for your help

Best Answer

If your have version R2016a or later of the Signal Processing Toolbox, use the findchangepts (link) function.