finding equations of damped sine wave parameters with givethree data points
17 views (last 30 days)
Show older comments
I have three data points (x1,y1), (x2,y2), (x,y3). A damped sine wave of the form y = A exp(-k x) sin(w x + phi) is passing through them. w is known so we have three unknowns (A, k, phi). Can someone help me in getting equations for these three unknowns in terms of data points?
0 Comments
Accepted Answer
David Goodmanson
on 8 Jan 2018
Hi Deepak,
Although what John says must almost certainly be true in general, there is one special situation where you can get somewhere. That's when x1, x2 and x3 are equally spaced. The solution is analytic but it is not unique, and you would have to deal with that in the general case as well. If you divide eqn1 by eqn2 and eqn2 by eqn3, you get
y1/y2 = exp(-k*(x1-x2))*sin(w*x1+phi)/sin(w*x2+phi) % eqn 4
y2/y3 = exp(-k*(x2-x3))*sin(w*x2+phi)/sin(w*x3+phi) % eqn 5
If (x3-x2) equals (x2-x1) you can divide these two equations, eliminate k and arrive at
y1*y3*sin(w*x2+phi)^2 = y2^2*sin(w*x1+phi)*sin(w*x3+phi)
Then after messing around with trig functions you get
y1*y3*(s2+c2*tan(phi))^2 = y2^2*(s1+c1*tan(phi))*(s3+c3*tan(phi)) % eqn 6
% where s3 = sin(w*x3), c3 = cos(w*x3) etc.
You can solve the quadratic for tan(phi) and use atan to get an analytic expression for phi. Then you can back substitute that into eqn 4 or eqn 5 to get an analytic expression for k. Then you can back substitute that into one of the original equations to find A.
Whether this is all worth it is another question entirely. vpasolve will give a result whether x1,x2,x3 are equally spaced or not. But nonetheless …
Here is an example for equally spaced which provides two solutions. The code uses symbolic variables in eqn6 to solve for tan(phi). The expressions are shown in s6, and the answer is not particularly illuminating. Next it’s easy to solve for k (eqn 4a below), and solving for A is automatic.
One could plug the symbolic expressions of s6 into eqn 4a but things get increasingly unwieldy. It makes more sense to note that the whole process is analytic and just plug in numerical values. Phi is a two element column vector of solutions, same for k and A.
When the two corresponding functions A*exp(-k*x)*sin(w*x+phi) are plotted, you can see that both the curves are good solutions.
% set up an example to solve
A = 10;
k = 1/2;
phi = pi/6;
w = 2;
x123 = [1 2 3];
fun = (@(x) A*exp(-k*x).*sin(w*x+phi));
y123 = fun(x123);
% solve for t = tan(phi), two solutions to quadratic eqn.
syms t x1 x2 x3 w y1 y2 y3
eqn6 = y1*y3*(sin(w*x2)+cos(w*x2)*t)^2 == ...
y2^2*(sin(w*x1)+cos(w*x1)*t)*(sin(w*x3)+cos(w*x3)*t);
s6 = solve(eqn6,t)
% numerical result
w = 2;
x1 = x123(1); x2 = x123(2); x3 = x123(3);
y1 = y123(1); y2 = y123(2); y3 = y123(3);
phi = atan(double(subs(s6))) % two element column vector
% find k and A
k = -log((y1/y2)*(sin(w*x2+phi)./sin(w*x1+phi))) / (x1-x2) % eqn 4a
A = y1 ./ (exp(-k*x1).*sin(w*x1 + phi)) % eqn 1a
% plot solutions
x = 0:.001:5;
fun = (@(x) A.*exp(-k*x).*sin(w*x+phi));
plot(x,fun(x),x123,y123,'o')
2 Comments
John D'Errico
on 8 Jan 2018
Good idea by David. It only applies when the x variable lies in a linear sequence, because otherwise, k will not drop out.
More Answers (1)
John D'Errico
on 5 Jan 2018
Use fsolve. You have three nonlinear equations, with three unknowns.
2 Comments
John D'Errico
on 5 Jan 2018
Edited: John D'Errico
on 5 Jan 2018
You have modified your question to ask how to get the equations. Why do you need help in getting the equations?
y1 = A*exp(-k*x1)*sin(w*x1 + phi)
y2 = A*exp(-k*x2)*sin(w*x2 + phi)
y3 = A*exp(-k*x3)*sin(w*x3 + phi)
WTP?
Still. Use fsolve. Or solve. Or vpasolve. (It is possible that solve might not find an analytical solution. No surprise if not.)
John D'Errico
on 5 Jan 2018
Edited: John D'Errico
on 5 Jan 2018
No. There will be no analytical solution. You want someone to write magic for you. Wave their wand, and give you a solution that does not exist.
THERE IS NO ANALYTICAL SOLUTION. I have now verified this claim using solve. At least, there is no solution that solve can find. I trust solve here, that this implies no analytical solution, because this coincides with my own intuition. If you don't believe me, then believe solve:
syms x1 y1 x2 y2 x3 y3 w phi A k
Eq1 = y1 - A*exp(-k*x1)*sin(w*x1 + phi);
Eq2 = y2 - A*exp(-k*x2)*sin(w*x2 + phi);
Eq3 = y3 - A*exp(-k*x3)*sin(w*x3 + phi);
solve(Eq1,Eq2, Eq3,A,phi,k)
Warning: Unable to find explicit solution. For options, see help.
> In solve (line 317)
ans =
struct with fields:
A: [0×1 sym]
phi: [0×1 sym]
k: [0×1 sym]
You need to use a numerical solver, one that can take the given values, and return numeric results. That is either fsolve or vpasolve. In either case, you need to have KNOWN numerical values for {x1, x2, x3, y1, y2, y3, w}.
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!