%EEMAG1 Fall 99
%S. Mandayam, ECE, Rowan University
%Space varying scalar and vector fields

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

