Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x=-5:0.02:4;
- y=x;
- [X,Y]=meshgrid(x,y);
- 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);
- [C,h]=contour(X,Y,Z,[0.1 1 5 20 50 100 200]);
- clabel(C,h);
- p=[8,1,-13,4,7,-6];
- for k=1:5
- a=input('a-? ');
- b=input('b-? ');
- [x0 z0]=fminsearch('fzyu',[a,b]);
- x0
- z0
- end
- ////////////////////////
- function fi = fzyu(x)
- 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);
- endfunction
- ////////////////////////
- x=-1:0.05:3;
- y=((x-2).^2)+3*cos(4*x)+2*x-5;
- plot(x,y);
- n=input('mins-?');
- for k=1:n
- disp('min');
- disp(k);
- a=input('a-?');
- b=input('b-?');
- [x0 y0]=fminsearch('fzh1',[a,b])
- x0
- y0
- end
- n=input('maxs-?');
- for k=1:n
- disp ('max');
- disp(k);
- a=input('a-?');
- b=input('b-?');
- [x0 y0]=fminsearch('fzh2',[a,b])
- x0
- -y0
- end
- ///////////////////////
- function f1=fzh1(x)
- f1=((x-2).^2)+3*cos(4*x)+2*x-5;
- endfunction
- function f2=fzh2(x)
- f2=-(((x-2).^2)+3*cos(4*x)+2*x-5);
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement