Advertisement
czlowiekzgon

matlab

Mar 30th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. clc
  2. clear all
  3. close all
  4.  
  5. x = -5:0.1:5;
  6. y = -5:0.1:5;
  7.  
  8. %f=@(x,y) 2.*x.^2+y.^2+x.*y-6.*x-5.*y+8;
  9. epsilon = 0.05;
  10. x0 = 5;
  11. y0 = 5;
  12. xprev = 0;
  13. yprev = 0;
  14. odlegosc = sqrt(x0 - xprev)^2 + (y0 - yprev)^2;
  15. while odlegosc > epsilon
  16.  
  17. yprev = y0;
  18. y0 = minY(x0);
  19.  
  20. xprev = x0;
  21. x0 = minX(y0);
  22.  
  23. odlegosc = sqrt(x0 - xprev)^2 + (y0 - yprev)^2;
  24. end
  25. x0
  26. y0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement