I wish to plot 2d gaussian in matlab, and here is the code and generated graph.
x=0:.02:1; y=x;
r = 0.2; %set standard deviation
[X,Y]=meshgrid(x,y);
Z=exp(-((X-0.5).^2+(Y-0.5).^2)/(2*r^2));
mesh(X,Y,Z)
colormap([0 0 0]);
Since we can get a 2d gaussian from multipying two 1d gaussian:

I wish to do the same thing to "Z" in my code:
x=0:.02:1; y=x;
r = 0.2; %set standard deviation
[X,Y]=meshgrid(x,y);
Z=exp(-((X-0.5).^2)/(2*r^2)) * exp(-((Y-0.5).^2)/(2*r^2));
mesh(X,Y,Z)
colormap([0 0 0]);
But here is what I got: a flat plane

I do not really understand why. Could someone shed some light? Thanks!
