I want to write a function that calculate the voltage for three junctions A,B and C in the picture below if we know the voltage of V. (G=0V). Did anyone write it before?

4 ビュー (過去 30 日間)
  1 件のコメント
DGM
DGM 2021 年 11 月 29 日
編集済み: DGM 2021 年 11 月 29 日
Express the currents entering and leaving those three nodes as functions of the node voltages V,Va,Vb,Vc. Expand and rearrange to form a simple linear system of equations. Solve.

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

採用された回答

Milad Mehrnia
Milad Mehrnia 2021 年 11 月 30 日
function ans = voltage(V,R)
E1 = [R(2)*R(7)+R(1)*R(2)+R(1)*R(7) -R(1)*R(2) 0]
E2 = [-R(3)*R(8)*R(4) R(4)*R(8)*R(7)+R(3)*R(8)*R(4)+R(3)*R(7)*R(4)+R(3)*R(7)*R(8) -R(3)*R(7)*R(4)];
E3 = [0 -R(5)*R(6) R(8)*R(6)+R(5)*R(6)+R(5)*R(8)];
E = [E1;E2;E3];
b = V.*[R(2)*R(7);R(4)*R(8)*R(7);R(8)*R(6)];
ans = E\b;
end
  3 件のコメント
DGM
DGM 2021 年 11 月 30 日
編集済み: DGM 2021 年 11 月 30 日
Disregarding the requirement to implement as a function, this is equivalent but perhaps a bit more compact. Sometimes it's neater to use one or the other method.
% some inputs
V = 10;
R = [1 1 1 1 1 1 1 1];
% coefficient terms
A = [-(1/R(1) + 1/R(2) + 1/R(7)) 1/R(7) 0; ...
1/R(7) -(1/R(3) + 1/R(4) + 1/R(7) + 1/R(8)) 1/R(8); ...
0 1/R(8) -(1/R(5) + 1/R(6) + 1/R(8))];
% constant terms
b = -[V/R(1); V/R(3); V/R(5)];
Vx = A\b % node voltages
The terms are derived from the expressions of presumed node currents.
Then factored as necessary. Both are equivalent and will give a numeric solution for numeric inputs.
If it's desired to find a fully symbolic solution instead:
syms V Va Vb Vc R1 R2 R3 R4 R5 R6 R7 R8
% these are implicitly treated as equal to zero.
IA = (V-Va)/R1 - Va/R2 - (Va-Vb)/R7;
IB = (V-Vb)/R3 - Vb/R4 - (Vb-Vc)/R8 + (Va-Vb)/R7;
IC = (V-Vc)/R5 - Vc/R6 + (Vb-Vc)/R8;
S = solve([IA,IB,IC],[Va Vb Vc]); % solve
% show the solutions
S.Va
S.Vb
S.Vc
Benjamin Asakov
Benjamin Asakov 2021 年 11 月 30 日
Thank you both guys. I really don’t know how to appreciate it.
Didn’t expect to have the answer less than a day. And not just one but three answers.
Really thank you

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by