MATLAB: Plotting a 3d gaussian function using surf

3d plotgaussian

Let me start off by saying that I am extremely new to MATLAB. I would to use these functions and turn them into a 3d plot using surf. I have already made a mesh grid of my x and y but I am confused on how to plug my gaussian function in as Z. I would like the surf plot to look like this http://i.stack.imgur.com/QiTPe.png
x=randn(1,10000);
y=x';
[X,Y]=meshgrid(x,y);
z=(1000/sqrt(2*pi)*exp(-X.^2/2))
surf(x,y,z);shading interp
Thanks in advance for the help.

Best Answer

This works:
N = 3.0;
x=linspace(-N, N);
y=x;
[X,Y]=meshgrid(x,y);
z=(1000/sqrt(2*pi).*exp(-(X.^2/2)-(Y.^2/2)));
surf(X,Y,z);
shading interp
axis tight
Experiment to get the result you want.
Related Question