MATLAB: get members of histogram populations EXCLUDING those inbetween
Assumption

Your noise is Gaussian.

Proposed solution

Compute the histogram of your data. There will be two peaks, as in the histogram you've shown. Extract the approximate positions of the peaks and use these values as starting values to fit two Gaussian curves to both peaks, each with the fit parameters $\mu$ (mean signal, i.e. position of the Gaussian) and $\sigma$ (width of the Gaussian). 

Your signal will then be the difference in positions of the Gaussians, and your noise is given by their widths.

Yes, there will still be contributions from the sides of the rect-pulse. However, there probably is no way to fully get rid of them, since you need some criterion to tell apart plateau values from values from the side lobes, what always becomes problematic if a point is close to the baseline/plateau. You could mitigate this effect by using the histogram values not only as datapoints for the fit, but also as fit weights. By doing so, the (low number of) side lobe values gets less weight compared to the (high number of) plateau/baseline values.