czlowiekzgon

matlab2

Mar 30th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function wynik = minY(x)
  2. %UNTITLED3 Summary of this function goes here
  3. % Detailed explanation goes here
  4. stala = x;
  5. f=@(y) 2.*stala.^2+y.^2+stala.*y-6.*stala-5.*y+8;
  6.  
  7. a = -5;
  8. b = 5;
  9. e = 0.000001;
  10. x1=a+0.382*(b-a);
  11. x2=a+0.618*(b-a);
  12. while (b-a)>e
  13. if (f(x1)<f(x2))
  14. b=x2;
  15. else
  16. a=x1;
  17. end
  18. x1=a+0.382*(b-a);
  19. x2=a+0.618*(b-a);
  20. end
  21. wynik=(a+b)/2;
  22. end
Add Comment
Please, Sign In to add comment