Advertisement
Guest User

eight-prog

a guest
Dec 14th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.00 KB | None | 0 0
  1. x=-5:0.02:4;
  2. y=x;
  3. [X,Y]=meshgrid(x,y);
  4. Z=abs(8*(X+i*Y).^5+(X+i*Y).^4-13*(X+i*Y).^3+4*(X+i*Y).^2+7*(X+i*Y)-6);
  5. [C,h]=contour(X,Y,Z,[0.1 1 5 20 50 100 200]);
  6. clabel(C,h);
  7. p=[8,1,-13,4,7,-6];
  8. for k=1:5
  9. a=input('a-? ');
  10. b=input('b-? ');
  11. [x0 z0]=fminsearch('fzyu',[a,b]);
  12. x0
  13. z0
  14. end
  15.  
  16. ////////////////////////
  17.  
  18. function fi = fzyu(x)
  19. fi=abs(8*(x(1)+i*x(2))^5+(x(1)+i*x(2))^4-13*(x(1)+i*x(2))^3+4*(x(1)+i*x(2))^2+7*(x(1)+i*x(2))-6);
  20. endfunction
  21.  
  22. ////////////////////////
  23.  
  24. x=-1:0.05:3;
  25. y=((x-2).^2)+3*cos(4*x)+2*x-5;
  26. plot(x,y);
  27. n=input('mins-?');
  28. for k=1:n
  29. disp('min');
  30. disp(k);
  31. a=input('a-?');
  32. b=input('b-?');
  33. [x0 y0]=fminsearch('fzh1',[a,b])
  34. x0
  35. y0
  36. end
  37. n=input('maxs-?');
  38. for k=1:n
  39. disp ('max');
  40. disp(k);
  41. a=input('a-?');
  42. b=input('b-?');
  43. [x0 y0]=fminsearch('fzh2',[a,b])
  44. x0
  45. -y0
  46. end
  47.  
  48. ///////////////////////
  49.  
  50.  
  51. function f1=fzh1(x)
  52. f1=((x-2).^2)+3*cos(4*x)+2*x-5;
  53. endfunction
  54. function f2=fzh2(x)
  55. f2=-(((x-2).^2)+3*cos(4*x)+2*x-5);
  56. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement