ex0408.m

来自「基于MATLAB的微粒群工具箱」· M 代码 · 共 28 行

M
28
字号
clear;
vizAxes = plot(0,0, 'o');
axis([-10 10 -10 10 -10 10]);   %Initially set to a cube of this size
axis square;
grid off;
set(vizAxes,'EraseMode','xor','MarkerSize',8); %Set it to show particles.
pause(1);
GBest = [1 2 3 4 5 6 7 8 9];
Dimensions = 9;
N = Dimensions / 3;
X = reshape(GBest,3,N);
set(vizAxes,'XData',X(3,:).*cos(X(1,:)).*cos(X(2,:)),'YData', X(3,:).*sin(X(1,:)).*cos(X(2,:)), 'ZData', X(3,:).*sin(X(2,:)));

% Generation = 500;
% 
% GenDiv = 100;
% xAx = GBest(1);
% yAx = GBest(2);
% zAx = GBest(3);
% 
% zf = 100 * 50/Generation; %zoom factor
% 
% if rem(Generation, GenDiv) == 0
%     axis([xAx-zf xAx+100 yAx-zf yAx+zf zAx-zf zAx+zf]);
% end
% 
% title(Generation);
% drawnow;

⌨️ 快捷键说明

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