To Write a function called voltage that computes the voltages at different junctions in electrical circuit. after writing the program the output is not coming please help
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function sol = voltage(V,R)
M =[R(2)*R(7)+R(1)*R(2)+R(1)*R(7),-R(1)*R(2),0;-R(3)*R(4)*R(8),R(4)*R(7)*R(8)+R(3)*R(4)*R(8)+R(3)*R(4)*R(7)+R(3)*R(7)*R(8),-R(3)*R(4)*R(7);0,-R(5)*R(6),R(6)*R(8)+R(5)*R(6)+R(5)*R(8)];
y =V*[R(2)*R(7);R(4)*R(7)*R(8);R(6)*R(8)];
SOL=M\y;
end
0 Kommentare
Antworten (5)
Ritvij Sahasrabuddhe
am 2 Jan. 2021
You have used 'sol' and 'SOL' as function def output, which are considered 2 different variables
0 Kommentare
Anthony
am 1 Mär. 2021
Bearbeitet: DGM
am 4 Mär. 2023
function sol = voltage(V,R)
M =[R(2)*R(7)+R(1)*R(2)+R(1)*R(7),-R(1)*R(2),0;
-R(3)*R(4)*R(8),R(4)*R(7)*R(8)+R(3)*R(4)*R(8)+R(3)*R(4)*R(7)+R(3)*R(7)*R(8),-R(3)*R(4)*R(7);
0,-R(5)*R(6),R(6)*R(8)+R(5)*R(6)+R(5)*R(8)];
y =V*[R(2)*R(7);R(4)*R(7)*R(8);R(6)*R(8)];
sol=M\y;
end
0 Kommentare
Tapan Chahar
am 15 Mai 2022
Bearbeitet: DGM
am 4 Mär. 2023
function [X]=voltage(V,R)
% Writing equations about the 3 node points using Kirchoffs Law & rewritting
% them in terms of matrix we get
if R(1)==0||R(3)==0||R(5)==0
% When resistor R1 =0
if R(1)==0
A=[(1/R(3)+1/R(7)+1/R(8)+1/R(4)),(-1/R(8)) ; (-1/R(8)),(1/R(5)+1/R(8)+1/R(6))];
b=[(V/R(3)+V/R(7));V/R(5)];
XX=A\b;
X=[V;XX];
end
% When resistor R3 =0
if R(3)==0
A=[(1/R(1)+1/R(2)+1/R(7)),0 ; (-1/R(8)),(1/R(5)+1/R(8)+1/R(6))];
b=[(V/R(1)+V/R(7));V/R(5)];
XX=A\b;
X=[XX(1);V;XX(2)];
end
% When resistor R5 =0
if R(5)==0
A=[(1/R(1)+1/R(2)+1/R(7)),(-1/R(7)) ; (-1/R(7)),(1/R(3)+1/R(4)+1/R(7)+1/R(8))];
b=[V/R(1);V/R(3)+V/R(8)];
XX=A\b;
X=[XX;V];
end
% When both resistor R3 & R5 are =0
if R(3)==0&R(5)==0
A=[(1/R(1)+1/R(2)+1/R(7))];
b=[V/R(1)+V/R(7)];
XX=A\b;
X=[XX;V;V];
end
% When both resistor R1 & R3 are =0
if R(1)==0&R(3)==0
A=[(1/R(5)+1/R(6)+1/R(8))];
b=[V/R(5)+V/R(8)];
XX=A\b;
X=[V;V;XX];
end
% When both resistor R1 & R5 are =0
if R(1)==0&R(5)==0
A=[(1/R(3)+1/R(4)+1/R(7)+1/R(8))];
b=[V/R(3)+V/R(7)+V/R(8)];
XX=A\b;
X=[V;XX;V];
end
% When resistor R1, R3 & R5 are =0
if R(1)==0&R(3)==0&R(5)==0
X=[V;V;V];
end
% When resistor R1,R3 & R5 are non zero
else
A=[(1/R(1)+1/R(2)+1/R(7)),(-1/R(7)),0 ; (-1/R(7)),(1/R(3)+1/R(7)+1/R(8)+1/R(4)),(-1/R(8)) ; 0,(-1/R(8)),(1/R(5)+1/R(8)+1/R(6))];
b=[V/R(1);V/R(3);V/R(5)];
X=A\b;
end
end
0 Kommentare
Tapan Chahar
am 15 Mai 2022
function X = voltage(V,R)
A = [ R(2)*R(7) + R(1)*R(2) + R(1)*R(7), -R(1)*R(2), 0;
-R(3)*R(4)*R(8), R(4)*R(7)*R(8) + R(3)*R(4)*R(8) + R(3)*R(4)*R(7) + R(3)*R(7)*R(8), -R(3)*R(4)*R(7);
0, -R(5)*R(6), R(6)*R(8) + R(5)*R(6) + R(5)*R(8) ];
b = V * [R(2)*R(7); R(4)*R(7)*R(8); R(6)*R(8)];
X = A \ b;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Circuits and Systems finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!