a = -1.5:.005:1.5;
    b = -0.75:.005:2.25;
    [X,Y] = meshgrid(a,b);
    Z = (1 - X).^2 + 105*(Y - X.^2).^2;
       
   
figure(1)
set(gcf,'Color',[1,1,1])
surf(a,b,Z)
shading interp
shading flat
colormap(hot)

figure(4)
    [Xc,Yc] = meshgrid(a,a);
set(gcf,'Color',[1,1,1])
    Zc = Xc.^2 + 2*Yc.^2 + .5*Xc.*Yc;
surfc(a,a,Zc)
shading interp
shading flat
colormap(hot)

%%
figure(5)
set(gcf,'Color',[1,1,1])
    a = -1.5:.1:1.5;
    [Xc,Yc] = meshgrid(a,a);
    Zc = - Xc.^2 + 1.5*Yc.^2 + 1.75*Xc.*Yc;
[px,py] = gradient(Zc,.2,.2);
contour(a,a,Zc,10), hold on,
quiver(a,a,px,py),
hold off
 
%%

figure(2)
a = -1.5:.005:1.5;
set(gcf,'Color',[1,1,1])
[c,h] = contourf(a,b,(Z),([.05  1 10  50 100 200 300 400 500]))
clabel((c),h);
colormap(cool)
axis square

%%
figure(3)
set(gcf,'Color',[1,1,1])
contourf(a,b,log(Z+eps),log([.05  1 10  50 100 200 300 400 500]))
colormap(hot)
axis square
for i = 1:4
    [x,y] = ginput(1); 
    z = (1 - x)^2 + 105*(y - x^2)^2;
    dZx = 2*(x-1) - 105*2*(y - x^2)*2*x;
    dZy =  105*2*(y - x^2);
    nor = sqrt(dZx^2 + dZy^2);

    h =  line([x x+dZx/nor],[y y+dZy/nor],'Marker','.','LineStyle','-','LineWidth',2,'Color',[0.25 0.25 0.25]);
    h =  line([x x+.5*dZy/nor],[y y-.5*dZx/nor],'LineStyle','--','LineWidth',1,'Color','k');
    h =  line([x x-.5*dZy/nor],[y y+.5*dZx/nor],'LineStyle','--','LineWidth',1,'Color','k');
%annotation('arrow',[x x+dZx/nor],[y y+dZy/nor]);
end
Modifié le: mardi 5 novembre 2013, 14:37