// Lignes de niveau deff('[z]=myphi(x,y)','z=(x.^2)/2+(y.^2).*cos(x)'); x=-5:0.1:5; y=x; [m n]=size(x); z=zeros(n,n); for i=1:n for j=1:n z(i,j)=myphi(x(i),y(j)); end end clf(); colorbar(min(z),max(z)); Sgrayplot(x,y,z); title('Lignes de niveau de phi'); //pause; // Gradient à pas fixe deff('[Y]=mygradphi(X)','Y=[X(1).^2-X(2)*sin(X(1)),2*X(2).*cos(X(1))]'); rho=0.9; X=[1,1]; Y=X; for i=1:19 Y=Y-rho*mygradphi(Y); X=[X;Y]; end rho=1.1; Xbis=[1,1]; Ybis=Xbis; for i=1:19 Ybis=Ybis-rho*mygradphi(Ybis); Xbis=[Xbis;Ybis]; end plot(X(:,1),X(:,2),'ro',Xbis(:,1),Xbis(:,2),'b*'); legend('moins','plus');