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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by