# Solving for unisolated variable

5 views (last 30 days)
Jonathan on 22 Nov 2013
Commented: Jonathan on 23 Nov 2013
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

Walter Roberson on 22 Nov 2013
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 CommentsShowHide 1 older comment
Walter Roberson on 23 Nov 2013
I used a symbolic engine.

Roger Stafford on 23 Nov 2013
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.
Jonathan on 23 Nov 2013
Interesting... Thank you very much. I'll let you know if it accomplishes the task!