% x^5-x^2*y*z+z*x+y^2-z^3 clear clc tic beep prompt = {'Enter Pop size:','Enter C1:','Enter C2:'}; title = 'PSO parametr'; numlines = 1; def = {'','',''}; answer = inputdlg(prompt,title,numlines,def); assignin('base','pop',answer{1}); assignin('base','c1',answer{2}); assignin('base','c2',answer{3}); s=rand(20,4).*200.-100; for i=1:20 s(i,4)=s(i,1)^5-(s(i,1)^2)*s(i,2)*s(i,3)+s(i,3)*s(i,1)+s(i,2)^2-s(i,3)^3-10; end pbest=s; gbest=min(s(:,4)); for i=1:20 if s(i,4)==gbest gxbest=s(i,1); gybest=s(i,2); gzbest=s(i,3); end end v=zeros(20,3).*20.+0; c1=1.7; c2=1.8; loop=1; while loop==1 w=0.4+rand*0.5; for i=1:20 v(i,1)=w*v(i,1)+c1*rand*(pbest(i,1)-s(i,1))+c2*rand*(gxbest-s(i,1)); s(i,1)=s(i,1)+v(i,1); v(i,2)=w*v(i,2)+c1*rand*(pbest(i,2)-s(i,2))+c2*rand*(gybest-s(i,2)); s(i,2)=s(i,2)+v(i,2); v(i,3)=w*v(i,3)+c1*rand*(pbest(i,3)-s(i,3))+c2*rand*(gzbest-s(i,3)); s(i,3)=s(i,3)+v(i,3); s(i,4)=s(i,1)^5-(s(i,1)^2)*s(i,2)*s(i,3)+s(i,3)*s(i,1)+s(i,2)^2-s(i,3)^3-10; if abs(s(i,4))