How can I build a circuit solver in matlab ?
39 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am a beginner in Matlab. I want to bulid a program which will take input the nodes and the resistance,current source or voltage source present in between the nodes and will show me the output of the branch currents along with the node voltages.
This is the code I found in a blog http://matlabbyexamples.blogspot.com/2011/11/circuit-solver-using-matlab-programming.html and modified a little bit. This code only shows output of the node voltages.
NetList=input('input node and resistance');
Vnod=input('input voltage and node');
%NetList=[1 2 2; 1 3 4; 2 3 5.2; 3 4 6; 2 4 3];
%Vnod=[1 6; 4 0];
l=size(NetList,1);
N=max([NetList(:,1) ;
NetList(:,2)]);
A=zeros(N,N);
B=zeros(N,1);
for i=1:l
n1=NetList(i,1);
n2=NetList(i,2);
if n1==n2
else
A(n1,n2)=A(n1,n2)-1/NetList(i,3);
A(n2,n1)=A(n2,n1)-1/NetList(i,3);
A(n1,n1)=A(n1,n1)+1/NetList(i,3);
A(n2,n2)=A(n2,n2)+1/NetList(i,3);
end
end
for i=1:size(Vnod,1)
A(Vnod(i,1),:)=zeros(1,N);
A(Vnod(i,1),Vnod(i,1))=1;
B(Vnod(i,1),1)=Vnod(i,2);
end
Vo=A\B;
disp(Vo);
It can solve the following types of circuits taking input as matrix and give output only the node voltages
But I can't solve the circuits in which voltage source is present between any two nodes other than ground.
I want to build a simple program which will solve the above problem and give output the branch currents along with the node voltages.
1 comentario
Emanuele Zanetti
el 17 de Jun. de 2019
Hello,
I have the same issue. Did you find a solution for this problem?
Respuestas (2)
Bardo
el 25 de Feb. de 2020
Hi,
you need to familiarize yourself with MNA equations, see a nice explanation in
0 comentarios
Andy Zambell
el 23 de Mayo de 2024
Building a circuit simulator in MATLAB is no small task. For everyone, I recommend looking at the Circuit Simulation Onramp to familiarize yourself with the circuit simulation capabilities of Simscape.
0 comentarios
Ver también
Categorías
Más información sobre Electrical Sensors en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!