资源简介
对于电网络理论中的节点电压法编写的matlab程序,仅供大家参考
代码片段和文件信息
clc
clear
disp(‘节点总数为:‘);
N=input(‘节点总数为: ‘);
U=zeros(NN);%This array is used to store the information of voltagedifference%
R=ones(NN);%This array is used to store the information of impetance%
for a=1:N%to initial the resistance between any nodes to be infinite namely oc.
for b=1:N
R(ab)=realmax;
end
end
flag=1;
bad_nodes=‘‘; %Nodes at which no equations can be formulated
while flag==1
type=menu(‘Select type of the component‘‘Resistor‘‘Capacitor‘‘Inductance‘‘VoltageSource‘‘End‘);
switch type
case 1
node1=input(‘Enter the first terminal of the component: ‘);
node2=input(‘Enter the second terminal of the component: ‘);
parameter=input(‘Enter its resistance/??: ‘);
R(node1node2)=parameter;
R(node2node1)=parameter;
case 2
node1=input(‘Enter the first terminal of the component: ‘);
node2=input(‘Enter the second terminal of the component: ‘);
parameter=input(‘Enter its capacitance/F: ‘);
w=input(‘Enter its angular frequency/rads: ‘);
R(node1node2)=-j/(w*parameter);
R(node2node1)=-j/(w*parameter);
case 3
node1=input(‘Enter the first terminal of the component: ‘);
node2=input(‘Enter the second terminal of the component: ‘);
parameter=input(‘Enter its inductance/H: ‘);
w=input(‘Enter its angular frequency/rads: ‘);
R(node1node2)=j*w*parameter;
R(node2node1)=j*w*parameter;
case 4
node1=input(‘Enter the first terminal of the component: ‘);
node2=input(‘Enter the second terminal of the component: ‘);
parameter=input(‘Enter its voltage/V: ‘);
U(node1node2)=parameter;
U(node2node1)=-parameter;
bad_nodes=strcat(bad_nodesnum2str(node1));
bad_nodes=strcat(bad_nodesnum2str(node2));
case 5
flag=0; %Exit
评论
共有 条评论