I need to solve a system of equations, without the syms command.

2 ビュー (過去 30 日間)
Petch Anuwutthinawin
Petch Anuwutthinawin 2021 年 7 月 29 日
編集済み: Cris LaPierre 2021 年 7 月 29 日
%I have a system of equations based off of Kirchoff law (e1-e6) that are
%all simultaneously true. The code works to solve for i4 which is the
%answer needed, but I have to do it without the syms command.
syms i1 i2 i3 i4 i5 i6
e1=v-R2*i2-R4*i4==0; %given equations 1-6
e2=-R2*i2+R1*i1+R3*i3==0;
e3=-R4*i4-R3*i3+R5*i5==0;
e4=i6==i1+i2;
e5=i2+i3==i4;
e6=i1==i3+i5;
eqns=[e1,e2,e3,e4,e5,e6];
vars=[i1 i2 i3 i4 i5 i6];
[A,b] = equationsToMatrix(eqns,vars);
X=double(A\b);
i4=X(4)
%How do I change this code so I can do it without the syms command?

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 7 月 29 日
Set up your system of linear equations and solve using left divide.
  8 件のコメント
Petch Anuwutthinawin
Petch Anuwutthinawin 2021 年 7 月 29 日
編集済み: Petch Anuwutthinawin 2021 年 7 月 29 日
But the six equations are all simultaneously true, how do I end up with just 3? Do I have to put all equations in terms of R only?
Cris LaPierre
Cris LaPierre 2021 年 7 月 29 日
編集済み: Cris LaPierre 2021 年 7 月 29 日
Sorry, I was thinking of using current loops. You can use nodes, too. You already have your equations. Just write them in matrix form. x contains the currents (i1-i6), A contains the value to multiply current by, and b contains the resulting value. Just keep track of how you multiply matrices (march across the row of A, and down the columns of x).
For example, you have the equation v-R2*i2-R4*i4==0. I'd rearrange this to be R2*i2+R4*i4=v. In matrix form, this is
To add one of your current equations, use 1s and 0s to create the math. For example, to add this equation: i6=i1+i2 to the matrix, I would rearrange it to be i1+i2-i6=0. In matrix form, that looks like this:
You have 6 unknowns, so you need six equations. Convert your remaining equations to matrix form, and then solve using left division.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by