Solving for unisolated variable

2 ビュー (過去 30 日間)
Jonathan
Jonathan 2013 年 11 月 22 日
コメント済み: Jonathan 2013 年 11 月 23 日
Hello all, I'm having a bit of trouble finding a method to solve a nonlinear equation. I've looked into "fsolve" a little but couldn't figure out if it would be effective. I'm using MatLab 2009.
Here is the equation, for ease I've simplified the constants to A,B,C. Variable to solve for is x.
x = arctan( (A - C*cos(x)) / (B*cos(x)) )
Which was derived from
A = B*sin(x) + C*cos(x)
Any help would be greatly appreciated... Rather than relying on MatLab to solve I would like to have x = F(A,B,C) where A,B,C are known but change with each iteration.
Another consideration is that this value needs to be found 5-10 times per second.
Thank you in advance! - Jon

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 11 月 22 日
There are two solutions:
T0 = sqrt(C^2*B^2 - B^2*A^2 + B^4);
X = [(C*A + T0)/(C^2+B^2), (C*A - T0)/(C^2+B^2)]; %just sign difference between two
Y = (A - C*X) / B;
atan2(Y, X)
  2 件のコメント
Jonathan
Jonathan 2013 年 11 月 23 日
Thanks for the quick response! I will be out of my lab until Sunday, so I can't verify until then. Can I ask either of you how you derived this solution? This information could be helpful to future projects and I'd love to see your work. Thanks!
Walter Roberson
Walter Roberson 2013 年 11 月 23 日
I used a symbolic engine.

サインインしてコメントする。


Roger Stafford
Roger Stafford 2013 年 11 月 23 日
Two solutions can be expressed as:
x = asin(A/sqrt(B^2+C^2)) - atan2(C,B);
and
x = pi - asin(A/sqrt(B^2+C^2)) - atan2(C,B)
Also either value with any integral multiple of 2*pi added or subtracted is a solution, thus giving infinitely many solutions.
  3 件のコメント
Roger Stafford
Roger Stafford 2013 年 11 月 23 日
My reasoning went this way. Starting with
A = B*sin(x) + C*cos(x)
notice that any pair of numbers B and C can always be represented by
B = sqrt(B^2+C^2)*cos(t)
C = sqrt(B^2+C^2)*sin(t)
for an appropriate angle t, which can be evaluated by
t = atan2(C,B)
(That in fact is one way to define the function atan2.) This gives
A = sqrt(B^2+C^2)*(cos(t)*sin(x)+sin(t)*cos(x))
= sqrt(B^2+C^2)*sin(x+t)
sin(x+t) = A/sqrt(B^2+C^2)
x + t = asin(A/sqrt(B^2+C^2))
x = asin(A/sqrt(B^2+C^2)) - t = asin(A/sqrt(B^2+C^2)) - atan2(C,B)
Jonathan
Jonathan 2013 年 11 月 23 日
Interesting... Thank you very much. I'll let you know if it accomplishes the task!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by