MATLAB Answers

lsqnonlin with tanh solutions

8 views (last 30 days)
Martin Elenkov
Martin Elenkov on 2 Aug 2017
Edited: Martin Elenkov on 3 Aug 2017
Hi guys,
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. :)
  2 Comments
Martin Elenkov
Martin Elenkov on 3 Aug 2017
Hi John,
I am searching for a least squares solution, that doesn't mean that the sum of squared difference should be zero (perfect fit), but I want to find its global minimum - best fit. At the same time, you are right. I am interested only in the anacrotic phase (the ascending part of the curve before the peak). Thanks for the question! I am new to posting and I find it hard to explains myself clearly.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 2 Aug 2017
The hyperbolic tangent may not be appropriate for a PPG signal.
However, if you want to use it, a more reasonable function would be one that shifts and scales:
fun=(@c) c(1) + tanh (x-c(2)) * c(3);
Here, ‘c(1)’ sets the lower limit, ‘c(2)’ shifts it, and ‘c(3)’ scales it.
  1 Comment
Martin Elenkov
Martin Elenkov on 3 Aug 2017
Hi Star Strider,
thank you for your response! Actually, the idea is not an original idea of mine. I read in a paper that the tanh parametrization in the form I gave gives the most accurate results and is the most robust to noise. Still I will give your suggestion a try, although this approach is missing slope adjustment.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!