MATLAB: How to find the point where a function oscillates around

matlab function misaligned zero reference

I have this function:
The zero is clearly misaligned with the function. MATLAB has some function to find it automatically?
Right now I'm adjusting it manually, but I have a lot of files and this is unfeasible.
Thank you for your attention.

Best Answer

If you have R2015b or later, and the Signal Processing Toolbox, the envelope (link) function, and particularly Envelope of Asymmetric Sequence (link) (see the third example using the 'peak' argument) might be the easiest way to determine the centre-line asymptote. The last value it returns would likely be what you want.