Does MATLAB have a way to solve for a variable in a nonlinear equation? (i.e. cos(x) + sin(y), solve for y in terms of x using symbols)

조회 수: 7 (최근 30일)
I have a very long, complicated equation in which is a variable for which I need solved. Basically, what I did was take the typical rotation matrix form and turn it in to a series of nonlinear equations.
xb = xa*(cosd(b)*cosd(c))+ya*((cosd(c)*sind(b)*sind(a))+(sind(c)*cosd(a)))+za*((sind(c)*sind(a)-(cosd(c)*sind(b)*cosd(a))));
yb = xa*(-sind(c)*cosd(b))+ya*(cosd(a)*cosd(c)-sind(a)*sind(b)*sind(c))+za*(sind(c)*sind(b)*cosd(a)+cosd(c)*sind(a));
zb = xa*(sind(b))+ya*(-cosd(b)*sind(a))+za*(cosd(a)*cosd(b));
I solved for two of the angles with respect to the other angle and the vector. What i need to do now is solve for the last angle in terms of just the vector.
Does anyone know if MATLAB can solve for a variable in terms of other variables?
Thank you!

답변 (2개)

Matt J
Matt J 2013년 11월 7일
편집: Matt J 2013년 11월 7일
If you have the Optimization Toolbox, there is fsolve(), but it is a numerical solver, i.e., the output is always a number.
If you have the Symbolic Toolbox, you can try to get a closed form symbolic expression for the solution using solve(), but a symbolic solution doesn't always exist for a set of equations.
Additionally, as I told you in an earlier thread, the solutions to the equations you've shown are highly non-unique.
  댓글 수: 11
Matt J
Matt J 2013년 11월 8일
편집: Matt J 2013년 11월 8일
Now I just need to solve for b.
I suspect you will not be able to solve for b. Again, because the solution is non-unique, there have to be some free variables left over. Think of trying to solve the single equation
x+y=1
for both x and y. I'm impressed that the solver took you as far as this, actually.
Walter Roberson
Walter Roberson 2013년 11월 8일
Make sure that n, p, q, r, x, y, z, a, b, c, are all defined as symbols and not functions or arrays. You might want to check with size()

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2013년 11월 7일
In general you can solve some kinds of equations using the Symbolic Toolbox if you have it (it is part of the Student Version license.)
I suggest you see previous discussions about rotation matrices, such as http://www.mathworks.co.uk/matlabcentral/answers/15411-recover-basic-rotations
  댓글 수: 1
Caraline
Caraline 2013년 11월 7일
Thank you! I will check out these threads. I have used solve, but it doesn't seem to work for arguments of type "sym" with trigonometric functions.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by