Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2010-04-27, 20:38   #1
applle_new
初级会员
 
注册日期: 2010-01-08
帖子: 1
声望力: 0
applle_new 正向着好的方向发展
默认 关于for循环得问题。急!!

更改一下,为了方便,我把源代码附上:

N=input('\N Enter the amount of nodes:N=');
M=input('\M Enter the amount of lines:M=');

B1=input('\B1 Enter the details of transmation line:B1=');
%first column stands for one termination
%second column stands for the other termination
%third column stands for the impendance of transmation line
%fourth column stands for the admittance between transmation line and
%ground
%fifth column stands for the ratio of transformer k
%on the sixth column, '1' represents P is on the high-voltage side;'0'
%represents P is on the low-voltage side

X=input('\X Enter the number of node and the impedance between them:X=');

%h=input('\h Enter the harmonics:h=');

Y1=zeros(N);

%***********set up harmonic frequency**********%
h1=[];h2=[];
for n=0:3
if n==0
h1=[h1,6*n+1];
else
h1=[h1,6*n+1];
h2=[h2,6*n-1];
end
end
h3=[h1,h2];
k=sort(h3);
%***********************************************%

for a=1:7 %**********the main 'for loop' for the total calculation**********%

%**********Y-MATRIX**********%
for i=1:N
if X(i,2)~=0;
p=X(i,1);
Y1(p,p)=1./X(i,2);
end

end

for i=1:M
if B1(i,6)==0
p=B1(i,1);q=B1(i,2);
else
p=B1(i,2);q=B1(i,1);
end
Y1(p,q)=Y1(p,q)-1./(B1(i,3)*B1(i,5));
Y1(q,p)=Y1(p,q);
Y1(q,q)=Y1(q,q)+1./(B1(i,3)*B1(i,5)^2)+B1(i,4)./2;
Y1(p,p)=Y1(p,p)+1./B1(i,3)+B1(i,4)./2;

end

G=real(Y1);B0=imag(Y1);
Y=G+j*k(1,a)*B0;
B=imag(Y);

disp('The Y-matrix is:');
disp(Y);

disp('G is:');
disp(G);

disp('B is:');
disp(B);
disp(k(1,a));


a=a+1;


end

输入变量为:N=5;M=5;B1=[1 2 0.105i 0 1.05 0;
2 3 0.024+0.065i 0.032i 1 0;
2 4 0.03+0.08i 0.04i 1 0;
3 4 0.018+0.05i 0.026i 1 0;
4 5 0.184i 0 0.96 1];
X=[1 0;2 0;3 0;4 0;5 0]

想得到得理想结果是:G一直不变;B值为k倍(k=1,5,7,11,13,17,19)
结果按照这个程序得到得结果为:G随a倍递增,B值没有找到规律。

想请各位帮帮忙!十分感谢!在线等~~
applle_new 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 18:33


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.