⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update_velocity.m

📁 malab语言实现bspline曲线拟合
💻 M
字号:
function v = update_velocity(NIND,chrom,W,C1,C2,Max_velocity,Max_Nv,pbest_chrom,gbest_chrom,v,m)% 更新粒子的速度for i = 1:1:NIND    a = rand();    b = rand();    v(i,1:m-1) = W*a*v(i,1:m-1) + C1*rand*(pbest_chrom(i,2:m) - chrom(i,2:m)) + C2*b*(gbest_chrom(2:m) - chrom(i,2:m));    v(i,m) = W*a*v(i,m) + C1*rand*(pbest_chrom(i,m+1) - chrom(i,m+1)) + C2*b*(gbest_chrom(m+1) - chrom(i, m+1));%      v(i,1:m-1) = W*rand*v(i,1:m-1) + C1*rand*(pbest_chrom(i,2:m) - chrom(i,2:m)) + C2*rand*(gbest_chrom(2:m) - chrom(i,2:m));%      v(i,m) = W*rand*v(i,m) + C1*rand*(pbest_chrom(i,m+1) - chrom(i,m+1)) + 4*rand*(gbest_chrom(m+1) - chrom(i, m+1));        % 限制粒子的运动速度    for j = 1:m-1        if abs(v(i,j)) > Max_velocity            if v(i,j) > 0                v(i,j) = Max_velocity;            else                v(i,j) = -Max_velocity;            end        end    end    if v(i,m) > Max_Nv        v(i,m) = Max_Nv;    elseif v(i,m) < -Max_Nv        v(i,m) = -Max_Nv;    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -