How do I solve this set of equations using MATLAB?

조회 수: 1 (최근 30일)
Goncalo Costa
Goncalo Costa 2022년 11월 8일
댓글: Torsten 2022년 11월 8일
I am trying to solve the following equations for the variable :
and
for that I wrote the following:
syms M n_1 n_2 n_3 th1 th2 th3
eqns = [M == ( (n_2*cos(th2) - n_3*cos(th3))/(n_2*cos(th2) + n_3*cos(th3)) )*...
( (n_2*cos(th2) + n_1*cos(th1))/(n_2*cos(th2) - n_1*cos(th1)) ) , ...
n_1*sin(th1) == n_2*sin(th2) , n_1*sin(th1) == n_3*sin(th3) ];
S = solve(eqns, [n_2])
But when I run the code I get that:
Empty sym: 0-by-1
What have I done wrong? How do I solve multiple equations?

답변 (2개)

Torsten
Torsten 2022년 11월 8일
You want to solve for one unknown - thus you only need one of the two equations.
If you want to solve for n1, n2 and n3, you have to specify this is the solve command.
But MATLAB cannot find an analytical solution, as you can see below.
syms M n_1 n_2 n_3 th1 th2 th3
eqns = [M == ( (n_2*cos(th2) - n_3*cos(th3))/(n_2*cos(th2) + n_3*cos(th3)) )*...
( (n_2*cos(th2) + n_1*cos(th1))/(n_2*cos(th2) - n_1*cos(th1)) ) , ...
n_1*sin(th1) == n_2*sin(th2) , n_1*sin(th1) == n_3*sin(th3) ];
S = solve(eqns, [n_1,n_2,n_3])
S = struct with fields:
n_1: [0×1 sym] n_2: [0×1 sym] n_3: [0×1 sym]
  댓글 수: 5
John D'Errico
John D'Errico 2022년 11월 8일
I would note there is pretty much never an analytical solution to a problem, where a variable appears both inside and outside of a trig function. Thus anything of the general form x*sin(x) = c, will generally have no algebraic/analytical solution, even if it has a numerical solution.
Torsten
Torsten 2022년 11월 8일
And this is the case somewhere ? The n_i are all outside the trig expressions.

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


Torsten
Torsten 2022년 11월 8일
As you can see from the below analysis, there is only the solution n_1 = n_2 = n_3 = 0 without conditions on the angles th1, th2 and th3.
syms M n_1 n_2 n_3 th1 th2 th3
f = M *(n_2*cos(th2) + n_3*cos(th3))*(n_2*cos(th2) - n_1*cos(th1)) - (n_2*cos(th2) - n_3*cos(th3))*(n_2*cos(th2) + n_1*cos(th1));
f = subs(f,[n_2 n_3],[n_1*sin(th1)/sin(th2),n_1*sin(th1)/sin(th3)])
f = 
f = simplify(f)
f = 

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by