How can I build a circuit solver in matlab ?

조회 수: 48 (최근 30일)
My Mine
My Mine 2016년 9월 19일
답변: Bardo 2020년 2월 25일
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
Emanuele Zanetti
Emanuele Zanetti 2019년 6월 17일
Hello,
I have the same issue. Did you find a solution for this problem?

댓글을 달려면 로그인하십시오.

답변 (1개)

Bardo
Bardo 2020년 2월 25일
Hi,
you need to familiarize yourself with MNA equations, see a nice explanation in

카테고리

Help CenterFile Exchange에서 Circuit Envelope Simulation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by