Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- x = 200*rand(1)-100;
- y = 200*rand(1)-100;
- dx = 0.1;
- for i=1:1000
- sused0 = [x,y];
- sused1 = [x,y-dx];
- sused2 = [x+dx,y];
- sused3 = [x+dx,y+dx];
- sused4 = [x, y+dx];
- sused5 = [x-dx,y+dx];
- sused6 = [x-dx,y];
- sused7 = [x-dx,y-dx];
- sused8 = [x+dx,y-dx];
- sused =[sused0;sused1;sused2;sused3;sused4;sused5;sused6;sused7;sused8];
- S = testfn1(sused);
- [m,indx]=min(S);
- if x==sused(indx,1) && y==sused(indx,2)
- break;
- else
- x=sused(indx,1);
- y=sused(indx,2);
- end
- graf(i) = m;
- end
- plot(graf)
- x
- y
Advertisement
Add Comment
Please, Sign In to add comment