clear all

x = -3:0.5:3;
y = -3:0.5:3;

[X,Y] = meshgrid(x, y);

%THIS IS WHAT YOU CHANGE... F(X,Y)!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%
Z = Y.^2 - X.^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%


%BEGIN PLOTTING

%this is the plot for that actual surface...
subplot(2,2,1);
surface(Z);
view(3)
grid on;

%this is the plot for the quasi-gradient vector field.
%the commented out part is if you want to impose the field on the surface.
subplot(2,2,2);
[U,V] = gradient(Z);
[W] = Z;
%mesh(X,Y,Z,'EdgeColor','black');
%hold on
quiver3(X,Y,Z,U,V,W);
grid on;
%hold off;

%this is a more specialized vector field...
%the surfnorm function creates a 3D matrix of vectors representing
%the vectors normal to the surface.
%im also including the surface to make it more clear.
subplot(2,2,3);
mesh(X,Y,Z,'FaceColor','red','EdgeColor','black');
alpha(.4); %makes it sorta see-through
hold on
[A,B,C] = surfnorm(Z);
quiver3(X,Y,Z,A,B,C);
grid on;
hold off

%this is the last and probably most important plot, the contour lines and
%the vector field!!!

subplot(2,2,4);
contour(Z);
hold on
[D,E] = gradient(Z);
quiver(D,E);
grid on
hold off