Created
April 28, 2021 01:41
-
-
Save n7275/8c95469fbe2d7f234eded87c79130c4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear; | |
clc; | |
pkg load symbolic; | |
sympref display unicode; | |
syms R0 R1 R2 R3 R4 R5 real; | |
syms V1 V2 V3 V4 V5 real; | |
ImpedanceMatrix5 = [R1+R0, -R1, 0, 0, 0;... | |
-R1, R1+R2, -R2, 0, 0;... | |
0, -R2, R2+R3, -R3, 0; | |
0, 0, -R3, R3+R4, -R4; | |
0, 0, 0, -R4, R4+R5]; | |
Res5 = inv(ImpedanceMatrix5)*[V1,V2-V1,V3-V2,V4-V3,V5-V4]'; | |
I1 = simplify(Res5(1)); | |
I2 = simplify(Res5(2)); | |
I3 = simplify(Res5(3)); | |
I4 = simplify(Res5(4)); | |
I5 = simplify(Res5(5)); | |
P51 = ccode(simplify((I1-I2)*V1)); | |
P52 = ccode(simplify((I2-I3)*V2)); | |
P53 = ccode(simplify((I3-I4)*V3)); | |
P54 = ccode(simplify((I4-I5)*V4)); | |
P55 = ccode(simplify((I5-0)*V5)); | |
clear I1 I2 I3 I4 I5; | |
ImpedanceMatrix4 = ImpedanceMatrix5(1:end-1,1:end-1); | |
Res4 = inv(ImpedanceMatrix4)*[V1,V2-V1,V3-V2,V4-V3]'; | |
I1 = simplify(Res4(1)); | |
I2 = simplify(Res4(2)); | |
I3 = simplify(Res4(3)); | |
I4 = simplify(Res4(4)); | |
P41 = ccode(simplify((I1-I2)*V1)); | |
P42 = ccode(simplify((I2-I3)*V2)); | |
P43 = ccode(simplify((I3-I4)*V3)); | |
P44 = ccode(simplify((I4-0)*V4)); | |
clear I1 I2 I3 I4; | |
ImpedanceMatrix3 = ImpedanceMatrix4(1:end-1,1:end-1); | |
Res3 = inv(ImpedanceMatrix3)*[V1,V2-V1,V3-V2]'; | |
I1 = simplify(Res3(1)); | |
I2 = simplify(Res3(2)); | |
I3 = simplify(Res3(3)); | |
P31 = ccode(simplify((I1-I2)*V1)); | |
P32 = ccode(simplify((I2-I3)*V2)); | |
P33 = ccode(simplify((I3-0)*V3)); | |
clear I1 I2 I3; | |
ImpedanceMatrix2 = ImpedanceMatrix3(1:end-1,1:end-1); | |
Res2 = inv(ImpedanceMatrix2)*[V1,V2-V1]'; | |
I1 = simplify(Res2(1)); | |
I2 = simplify(Res2(2)); | |
P21 = ccode(simplify((I1-I2)*V1)); | |
P22 = ccode(simplify(I2)*V2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment