
How can I draw the corresponding exponential decay curve to fit a damped sine wave?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MC
am 30 Dez. 2014
Kommentiert: John D'Errico
am 31 Dez. 2014
I want to draw the exponential curve that fits the peaks of the damped signal. I have done this very crudely by plotting the x and y values of the peaks on the same figure as the damped signal, but is there a better way to do this, without having to search values manually on the graph. I am relatively new to matlab so any help would be appreciated. Thanks!

0 Kommentare
Akzeptierte Antwort
John D'Errico
am 30 Dez. 2014
Bearbeitet: John D'Errico
am 31 Dez. 2014
You want to fit an exponential envelope function to the curve, essentially a least upper bound function. So the exponential mode would be something of the form...
Y_e = a + b*exp(-c*x)
If you know that the lower asymptote is exactly 1, then your model would be
Y_e = 1 + b*exp(-x)
We might estimate those coefficients by a simple log transformation, or we could use a nonlinear estimation. I'll show the log transformation. First, I'll create a damped sine wave curve as an example.
x = 0:100;
y = 1 + sin(x - pi/3).*exp(-0.2*x);
First, use only those points that fall above 1. So assuming vectors of points x and y...
ind = (y > 1);
x1 = x(ind);
% and transform y by a log transformation
y1 = log(y(ind) - 1);
A = [ones(numel(x1),1),x1(:)];
% estimate the model coeffs = lsqlin(A,y1(:),-A,-y1(:),[],[],[],[],[],optimset('algorithm','active-set','display','off'));
coeffs =
-0.00091842
-0.19999
Don't forget that when we logged the model, we transformed the coefficient b. We need to exponentiate
b = exp(coeffs(1))
b =
0.99908
c = coeffs(2);
% now plot the data and the curve
plot(x,y,'ro',x,1 + b*exp(c*x),'b-)

I used lsqlin from the optimization toolbox to do the fit. The fundamental ideas in this solution were:
- Transform the problem to linearity.
- Solve the linear least squares problem, such that all residuals had the proper sign.
If you don't know the lower asymptote for the curve, then you would need to use a nonlinear optimization tool for the fit. The constraints would be such that the necessary optimizer would be fmincon.
4 Kommentare
Image Analyst
am 31 Dez. 2014
John, what do you think about this approach using Hilbert: http://www.mathworks.com/matlabcentral/answers/168113#answer_163469
John D'Errico
am 31 Dez. 2014
I don't have hilbert. (Probably Signal Processing TB I presume?) It seems to work nicely enough, with the caveat of the Gibbs phenomena at the ends. It probably depends on one's goals for that envelope. Will those oscillations kill you? What will you use it for? Do you need a specific form for the solution?
For example, I did not mention that my SLM tools have inf and sup options in the fit, so they can fit least upper bound functions or greatest lower bound functions in the form of a spline. But if you really needed an exponential form, then a spline is useless.
Very often a solution is driven by your goals, and too often we, in the form of consultants, are not given those goals.
Weitere Antworten (1)
Scott Webster
am 30 Dez. 2014
I assume your damped sine wave data is experimental? (if you have an equation for it, then you should be able to get the parameters of your exponential from there)
Two ideas:
-curve fit the data with a custom damped sine wave function and then use the resulting parameters for the exponential to plot just that
-find the peak points (analyze derivatives?) and then just fit that with an exponential
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
