MATLAB 粒子群算法改错错误如下In an assignment A(I) = B,the number of elements in B andI must be the same.Error in ==> liziqun at 43J(i)=fitness(pid);程序如下clear all;clcm=10;dim=2; tmax=20000;wmin=0.4;wmax=1; c1=2;c2=2;for i=1:mfor j=
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 05:11:40
MATLAB 粒子群算法改错错误如下In an assignment A(I) = B,the number of elements in B andI must be the same.Error in ==> liziqun at 43J(i)=fitness(pid);程序如下clear all;clcm=10;dim=2; tmax=20000;wmin=0.4;wmax=1; c1=2;c2=2;for i=1:mfor j=
MATLAB 粒子群算法改错
错误如下
In an assignment A(I) = B,the number of elements in B and
I must be the same.
Error in ==> liziqun at 43
J(i)=fitness(pid);
程序如下
clear all;
clc
m=10;
dim=2;
tmax=20000;
wmin=0.4;
wmax=1;
c1=2;c2=2;
for i=1:m
for j=1:dim
vmax(i,j)=0.02;
vmin(i,j)=-0.02;
xmin(:,1)=1e-12;
xmax(:,1)=1e-9;
xmin(:,2)=3.98;
xmax(:,2)=4;
end
end
for i=1:m
for j=1:dim
x(i,j)=rand(1)*(xmax(j)-xmin(j))+xmin(j);
end
end
for i=1:m
for j=1:dim
v(i,j)=rand(1)*vmax(j);
end
end
pbest_position=zeros(m,dim);
for i=1:m
pid=x(i,:);
J(i)=fitness(pid);
end
pbest=J;%每个粒子的当前最优适应值
pbest_position=x;%每个粒子的最佳位置值 %求初始位置下种群的最佳位置
[gbest,gind]=min(J);%全群取最小适应值
pg=x(gind,:);
ht=0;%计算次数
while htvmax(i,j)
v(i,j)=vmax(i,j);
end
if v(i,j)
MATLAB 粒子群算法改错错误如下In an assignment A(I) = B,the number of elements in B andI must be the same.Error in ==> liziqun at 43J(i)=fitness(pid);程序如下clear all;clcm=10;dim=2; tmax=20000;wmin=0.4;wmax=1; c1=2;c2=2;for i=1:mfor j=
Y=abs(u2-U2)/abs(u2);