function coord_ascent(x,y,z,px,py,N,xstart,ystart)

xca(1)= xstart;
yca(1)= ystart;
zca(1)=func(xca(1),yca(1));

for i=1:2:N-1
  xca(i+1) = fmin('fxy',-10,10,[0,1.e-4],yca(i));
  yca(i+1) = yca(i);
  zca(i+1) = func(xca(i+1),yca(i+1));

  yca(i+2) = fmin('fyx',-10,10,[0,1.e-4],xca(i+1));
  xca(i+2) = xca(i+1);
  zca(i+2) = func(xca(i+2),yca(i+2));
end

hold off
contour(x,y,z,10)
hold on
quiver(x,y,px,py)
hold on
plot(xca,yca)
S = sprintf('Coordinate Ascent: N = %d',N);
title(S)
xlabel('x axis')
ylabel('yaxis')

