% 22.3MB1 Fall 01
% Yvan Petillot
% 2D Varying field. How to see them and generate them

close all; clear;
x = -2:.2:2; y = -1:.2:1;    
[xx,yy] = meshgrid(x,y);     
V = xx.*exp(-xx.^2-yy.^2); %generates the potential
figure(1);surf(x,y,V);shading interp;
rotate3d;
xlabel('x');ylabel('y');zlabel('V');
title('2-D space varying scalar field: V = x e^{-(x^2+y^2)}');
pause;
 
[ex,ey] = gradient(V,.2,.2); %Generates the field
figure(2);quiver(x,y,ex,ey,2);
xlabel('x');ylabel('y');
title('2-D space varying vector field');

