Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:28:13+00:00 2026-06-15T04:28:13+00:00

With the following code I’m able to draw the plot of a single 2D-Gaussian

  • 0

With the following code I’m able to draw the plot of a single 2D-Gaussian function:

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

This is the produced plot:

enter image description here

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 5×5 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).

enter image description here

Let me provide some mathematical details. The grid corresponds to a mixture of 2D-Gaussians summed as in the following equation:

enter image description here

In which each Gaussian has its own mean and deviation.

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 3×3.

Can you provide me (and explain to me) how can I do such a plot?
Thanks in advance for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:28:14+00:00Added an answer on June 15, 2026 at 4:28 am

    Indeed you said yourself, put (as an example just for the means)

    [X,Y]=meshgrid(x,y);  % //mesh
    
    g_centers = -3:3;    
    [x_g,y_g] = meshgrid(g_centers,g_centers); % //grid of centers (coarser)
    mu = [x_g(:) , y_g(:)];  % // mesh of centers in column
    
    
    z   = zeros(size(X));
    for i = 1:size(mu,1)
         z= z + exp(-((X-mu(i,1)).^2+(Y-mu(i,2)).^2)/( 2* .001) );
    end
    surf(X,Y,z);shading interp
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

following code works perfectly on FF and Chrome but not in IE8. $(window).keyup(function(e) {
following code work fine but 1 error $(document).ready( function() { $(#myCheckboxes input[type='checkbox']).change(function() { var
Following code has been picked up from this blog function! Privatize() let priorMethod =
Following code fails with a error message : t.cpp: In function `void test()': t.cpp:35:
Following code is intended to restrict selection of today's date in datepicker. jQuery(function ()
following code waits till dom ready jQuery(document).ready(function(){ what do i have to write to
Following code for passing an object to event handler is not working: $('a.another').live('click', function(e,
Following code is to track user location, var curr_loc; //global varible function displayLocation(loc) {
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.