global M;
creatematrix(2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%画ackley图。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ackley x from[-5 5]
% x=-5:0.01:5;
% [x,y]=meshgrid(x);
% temp1=x.^2+y.^2;
% temp2=cos(2*pi*x)+cos(2*pi*y);
% z=20+exp(1)-20*exp(-0.2*sqrt(temp1/2))-exp(temp2/2);
% axis([-5,5,-5,5]);
% meshc(x,y,z);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%画旋转的ackley图。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Rotated ackley x from[-5 5
% x=-5:0.01:5;
% [x,y]=meshgrid(x);
% for i=1:size(x,1)
% for j=1:size(y,1)
% p=[x(i,j),y(i,j)]';
% x(i,j)=M(1,:)*p;
% y(i,j)=M(2,:)*p;
% end
% end
% temp1=x.^2+y.^2;
% temp2=cos(2*pi*x)+cos(2*pi*y);
% z=20+exp(1)-20*exp(-0.2*sqrt(temp1/2))-exp(temp2/2);
% axis([-5,5,-5,5]);
% meshc(x,y,z);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%画cigar图。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%cigar
x=-5:0.01:5;
[x,y]=meshgrid(x);
z=x.^2+(10^4)*y.^2;
axis([-5,5,-5,5]);
meshc(x,y,z);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%画旋转的cigar图。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%rotated cigar x from [-5 5]
% x=-7:0.01:7;
% [x,y]=meshgrid(x);
% for i=1:size(x,1)
% for j=1:size(y,1)
% p=[x(i,j),y(i,j)]';
% x(i,j)=M(1,:)*p;
% y(i,j)=M(2,:)*p;
% end
% end
% z=x.^2+(10^4)*y.^2;
% axis([-7,7,-7,7]);
% meshc(x
群智能优化算法测试函数matlab源代码
本文介绍了如何使用Matlab实现群智能优化算法,并提供了相应的源代码实例,帮助读者理解和应用这些算法。
摘要由CSDN通过智能技术生成