Envelope detector for non-zero mean signal (Matlab)
You can calculate the mean of your nonzero signal, then substract it to the non-zero mean signal and calculate the envelope as you did before.

That will give you the envelope of the signal for the zero mean signal, but if you want to recover the envelope for the non-zero mean signal, then you just have to add to this envelope the initially calculated mean.