Solving a system of equations involving complex numbers

164 ビュー (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 4 月 21 日
コメント済み: Ameer Hamza 2020 年 4 月 21 日
The following code outputs a value for a and b with respect to the imaginary number i but the output is not fully simplified with the complex and real part separately factored. Is there a way to modify the code so it is of the form a+bi where a and b are rounded to a certain number of decimal places? This would ensure that the real and complex parts are each only one number rather than the sum of a radical and a rational numbers.
syms X Y Q t w v a b z c N theta m L g
eq1 = b-a == 10*(cosd(45)+i*sind(45));
eq2 = 3 == (a-b)/4+a*i/3 + b/(6*i)+b/12;
sol = solve([eq1 eq2], [b a]); %[a b c] = [theta' theta'' x'']
sol_b = simplify(sol.b)
solb = sol.b
  1 件のコメント
BALAJI KARTHEEK
BALAJI KARTHEEK 2020 年 4 月 21 日
The ans is in the form of cells, conversion of cells to arrays will give you the required results..

サインインしてコメントする。

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 21 日
編集済み: Ameer Hamza 2020 年 4 月 21 日
Try vpasolve()
syms X Y Q t w v a b z c N theta m L g
eq1 = b-a == 10*(cosd(45)+1i*sind(45));
eq2 = 3 == (a-b)/4+a*1i/3 + b/(6*1i)+b/12;
sol = vpasolve([eq1 eq2], [b a]); %[a b c] = [theta' theta'' x'']
Result
>> sol.a
ans =
18.513708498984760390413509793678 - 8.7431457505076198047932451031612i
>> sol.b
ans =
25.584776310850235634421953414726 - 1.6720779386421445607848014821127i
  2 件のコメント
Aleem Andrew
Aleem Andrew 2020 年 4 月 21 日
Thank you for your answer
Ameer Hamza
Ameer Hamza 2020 年 4 月 21 日
I am glad to be of help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEquation Solving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by