%% Divergence of 2-D Vector Field
% Specify 2-D coordinates and a vector field.

[x,y] = meshgrid(-8:2:8,-8:2:8);
Fx = 200 - (x.^2 + y.^2);
Fy = 200 - (x.^2 + y.^2);

% Plot the vector field components Fx and Fy.

quiver(x,y,Fx,Fy)

%
% Find the numerical divergence of the 2-D vector field. Plot the contour of the divergence.

D = divergence(x,y,Fx,Fy);
hold on
contour(x,y,D,'ShowText','on')

%
% Copyright 2020 The MathWorks, Inc.