%% Plot Surface
% Create a 2-D grid with uniformly spaced x-coordinates and y-coordinates in the interval [-2,2].

x = -2:0.25:2;
y = x;
[X,Y] = meshgrid(x);

%
% Evaluate and plot the function f(x,y) = xe^{-x^2-y^2} over the 2-D grid.

F = X.*exp(-X.^2-Y.^2);
surf(X,Y,F)

%
% Starting in R2016b, it is not always necessary to create the grid before operating over it. For example, computing the expression xe^{-x^2-y^2} implicitly expands the vectors x and y. For more information on implicit expansion, see Array vs. Matrix Operations.

surf(x,y,x.*exp(-x.^2-(y').^2))

% Copyright 2012 The MathWorks, Inc.