I have been banging my head over why the lsqnonlin function just wouldnt fit a parametrization of the type:
fun=(@c) c(1) * tanh ((x-c(2))/c(3))
to a standard PPG(Pulse Plethysmography) wave form.
The idea is that I want the parameters c(1) - amplitude; c(2) - phase shift and c(3) - steepness of the tanh, so I can characterize the beginning of the blood pressure pulse form PPG.
Here, the blue curve represents a tanh function with c=[10e8,15,12] and the orange curve is one blood pulse wave. I want the blue curve to shift in c until a least square solution (global max) is found, but the function always terminates in a local minimum with exit flag - 3 - Change in the residual was less than the specified tolerance.
In the future I also want to add a Hanning window to the tanh function so it looks even more to the blood pressure pulse, but for now I want to focus on this.
I hope the information I provided was enough for an answer, I will be glad to help you to help me. :)