% (* ::Package:: *) n=2000;% set the number of iteration xx0=[0.015,0.01,0.0001,-0.003,0.17];% initial points for 5 parameters global v x0=xx0; f=zeros(1,n); % matrix of function f fc=zeros(1,n); % matrx of function fc d=zeros(1,n); % matrix of grid length d w=zeros(1,n); % the width of rectangle w(1)=0.0001; % w(1) k=0; for i=1:n v=w(i); if v>=0.25 break; else if v>=0.14 && v<=0.147 x0=[0.007810714343299 0.009085812955299 0.082118620679615 -0.023480823344650 0.193494009846875]; elseif v>=0.17 && v<=0.173 x0=[0.009589531490591 0.008103702224192 0.082594222793638 -0.024691294264695 0.184242830823048]; elseif v>=0.173 && v<=0.178 x0=[0.002822167968750 0.003669531250000 0.002829589843750 -0.002689648437500 0.865884217861823]; end x0=fminsearch(@codecvhul2_2,x0); % find new initial point f(i)=feval(@codecvhul2_2,x0); % minimum value of w(i) d(i)=(0.1005-f(i))/0.5; % maximum d(i) fc(i)=f(i)+ 0.345*d(i); % f(w)+cd if fc(i)<=0.1005 % f(w)+cd<=B if i>=2 && w(i-1)+d(i-1)