title: Plot a grid of Gaussians with Matlab
body: <p>With the following code I'm able to draw the plot of a single 2D-Gaussian function:</p>
  
  <pre><code>x=linspace(-3,3,1000);
  y=x';               
  [X,Y]=meshgrid(x,y);
  z=exp(-(X.^2+Y.^2)/2);
  surf(x,y,z);shading interp
  </code></pre>
  
  <p>This is the produced plot:</p>
  
  <p><img src="https://i.stack.imgur.com/QiTPe.png" alt="enter image description here"></p>
  
  <p>However, I'd like to plot a grid having a specified number x of these 2D-Gaussians.
  Think of the following picture as an above view of the plot I'd like to produce (where in particular the grid is made of 5x5 2D-Gaussians). Each Gaussian should be weighed by a coefficient such that if it's negative the Gaussian is pointing towards negative values of the z axis (black points in the grid below) and if it's positive it's as in the above image (white points in the grid below).</p>
  
  <p><img src="https://i.stack.imgur.com/gv2J7.png" alt="enter image description here"></p>
  
  <p>Let me provide some mathematical details. The grid corresponds to a mixture of 2D-Gaussians summed as in the following equation:</p>
  
  <p><img src="https://i.stack.imgur.com/mJM4S.png" alt="enter image description here"></p>
  
  <p>In which each Gaussian has its own mean and deviation.</p>
  
  <p>Note that each Gaussian of the mixture should be put in a determined (X,Y) coordinate, in such a way that they are equally distant from each other. e.g think of the central Gaussian in (0,0) then the other ones should be in (-1,1) (0,1) (1,1) (-1,0) (1,0) (-1,-1) (0,-1) (1,-1) in the case of a grid with dimension 3x3.</p>
  
  <p>Can you provide me (and explain to me) how can I do such a plot?
  Thanks in advance for the help.</p>