主题:请帮我看看这个程序哪出了问题
主程序
N=50;
D=40;
position=rand(N,D)*pi;
velocity=rand(N,D)*0.1;
for m=1:N
fvalue(m)=fitness(position(m,:),D,m);
pbest(m,:)=position(m,:);
end
适应度函数源程序(fitness.m)
function F=fitness(position,D,m)
for i=0:80
EP(m,:)=sin(i/180*pi);
af(m,1)=eps(j*position(m,1));
for n=2:D
af(m,n)=eps(j*(n-1)/2*cos(i/180*pi)+position(m,n))+af(m,n-1);
end
AF(m,:)=af(m,D)/sqrt(2);
FP(m,:)=20*log(EP(m,:)*AF(m,:));
plot(i,FP,'r')
hold on
if FP<0
FP=-FP;
end
end
F(m,1)=(FP(m,1)-35)^2;
for i=2:80
F(m,i)=(FP(m,:)-35)^2+F(m,i-1);
end
F=F(m,80)
问题:在调用子程序时。position(N,D)只能通过一行,请哪位高手帮我看看吧,实在看不出问题出在哪
N=50;
D=40;
position=rand(N,D)*pi;
velocity=rand(N,D)*0.1;
for m=1:N
fvalue(m)=fitness(position(m,:),D,m);
pbest(m,:)=position(m,:);
end
适应度函数源程序(fitness.m)
function F=fitness(position,D,m)
for i=0:80
EP(m,:)=sin(i/180*pi);
af(m,1)=eps(j*position(m,1));
for n=2:D
af(m,n)=eps(j*(n-1)/2*cos(i/180*pi)+position(m,n))+af(m,n-1);
end
AF(m,:)=af(m,D)/sqrt(2);
FP(m,:)=20*log(EP(m,:)*AF(m,:));
plot(i,FP,'r')
hold on
if FP<0
FP=-FP;
end
end
F(m,1)=(FP(m,1)-35)^2;
for i=2:80
F(m,i)=(FP(m,:)-35)^2+F(m,i-1);
end
F=F(m,80)
问题:在调用子程序时。position(N,D)只能通过一行,请哪位高手帮我看看吧,实在看不出问题出在哪