Solving an equation with more than one unknown in matlab

1 回表示 (過去 30 日間)
mandy
mandy 2015 年 3 月 24 日
回答済み: Star Strider 2015 年 3 月 24 日
I am trying to find the solutions to the following two equations but since Matlab reads line to line I don't know how to enter these two equations so that it understands what I am trying to input. My code is
a=((-u/(10*j))+(s/(100*-j)))/((1/(j*100))-(1/10)-(1/10*j))
u=(((a/(10*j))-10)/(((1/100*j))+(1/10*j)))
s=25*exp(j*30*pi/180);

回答 (1 件)

Star Strider
Star Strider 2015 年 3 月 24 日
If you have the Symbolic Math Toolbox:
syms a u s
eqn1 = a==((-u/(10*j))+(s/(100*-j)))/((1/(j*100))-(1/10)-(1/10*j));
eqn2 = u==(((a/(10*j))-10)/(((1/100*j))+(1/10*j)));
eqn1 = subs(eqn1, {u}, {(((a/(10*j))-10)/(((1/100*j))+(1/10*j)))});
eqns = subs(eqn1, {s}, {25*exp(j*30*pi/180)});
a = vpasolve(eqns, a)
u = vpa(subs((((a/(10*j))-10)/(((1/100*j))+(1/10*j))),{a},{a}))
produces:
a =
88.519552132457129958929869921769 - 19.064250734748366881795919457402i
u =
- 80.472320120415572689936245383426 + 108.24022794068033352890538132491i
Could be more efficient, but this is the end of my day and I’m tired.

カテゴリ

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