%% 253 demo: no limit at origin
% 2015 W1: Colin Macdonald, public domain

x1 = linspace(-1, 1, 64*2);
y1 = x1;
y1 = linspace(-1, 1, 64*2);

[x, y] = meshgrid(x1, y1);

figure(1); clf;
f = x.*y ./ (x.^2 + y.^2);
%f = x.^2.*y ./ (x.^4 + y.^2);
%f = sin(x.^2) ./ y;

surf(x, y, f);

grid on
xlabel('x'); ylabel('y'); zlabel('z')

shading flat
camlight left
colorbar


pause


hold on
[C, H] = contour3(x, y, f);

% color the contours black more trouble than its worth!
if (exist('OCTAVE_VERSION', 'builtin') ~= 0)
  % octave
  set(H, 'linewidth', 3, 'linecolor', 'k');
else
  % matlab
  for i=1:length(H)
    h = H(i);
    set(h, 'linewidth', 3, 'edgecolor', 'k');
  end
end
