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

  • SEARCH
  • Home
  • 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 8626295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:59:30+00:00 2026-06-12T07:59:30+00:00

i tried to understand the 2D & 3D plotting function in Matlab, regarding to

  • 0

i tried to understand the 2D & 3D plotting function in Matlab, regarding to the image processing filters, like box-plots, gauss, mexican hats and so on…

I only got the kernel for the filters, e.g. a 5×5 matrix with the coefficents of each cell.
ezsurfc won’t work and I don’t understand it.
surf instead works, but I got no clue about the grids and how to make it more granular and smooth?

My understanding of surf is, that I need the same dimensions for each param, so how should I do it without making my kernel a 20×20 or even larger?
The idea is, that I get an output like the examples, i’ve posted. I mentioned the 20×20 grid mask of the filter, because it looks like that the smoothness and the flattening needs more coefficients than just 5×5… am I right or totally wrong?

I already tried the following matlab code, example for a laplace filter:

[x,y] = meshgrid(1:1:5); %create a 5x5 matrix for x and y (meshes)
z = [0 1 2 1 0; 1 3 5 3 1;2 5 9 5 2; 1 3 5 3 1;0 1 2 1 0]; % kernel 5x5
surf(x,y,z);

That gives me that output:
current output

So how do I generate a fine and granular 2D and a 3D plot out of that 5×5 kernel information?
Big thanks in advance!

P.S.: Hopefully my code indentions aren’t messed up… otherwise feel free to edit – it’s my first post on StackOverflow. 🙂

What I want to get, is like these two examples:
example no.1
example no.2

  • 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-12T07:59:32+00:00Added an answer on June 12, 2026 at 7:59 am

    You can use interp2 to find intermediate values on the same grid size for visualization purposes

    step = 0.1; % granularity
    [xn,yn] = meshgrid(1:step:5); % define finer grid
    zn = interp2(x,y,z,xn,yn); % get new z values 
    surf(xn,yn,zn);
    

    enter image description here

    Note that you will obtain the closest approximation to your original kernel using the default linear interpolation method, i.e. interp2(x,y,z,xn,yn,'linear'). Using other methods will result in smoother kernels to use, but their 3D shape will differ. So it depends on your use and application.

    Update:

    You can by-pass the ill-posed problem of up-sampling to a much higher resolution (the inverse reconstruction is possible only if the hypothetical “downsampling respects the Nyquist sampling rate) by trying to approximate your data with a known kernel, which then you can tune.

    For example, since you are give an example of a symmetric kernel, that decays isotropicaly around a maximum value, you can use a Gaussian function. MATLAB does so through fspecial function.

    Assume the underlying function (e.g. Gaussian) and use parameters defined from your current kernel (i.e. fitting a function to your data)

    % use max location, amplitude and std from your kernel
    max_z = max(z(:));
    std_z = std(z(:));
    
    % Set of tunable parameters (size of grid & granularity)
    bounds_grid = [30 30]; grid bounds
    step = 0.5; % resolution
    
    % Grid
    siz = (bounds_grid-1)/2;
    [x,y] = meshgrid(-siz(2):step:siz(2),-siz(1):step:siz(1));
    
    % Gaussian parameters
    s = std_z; m = 0;
    
    % Analytic function
    g = exp(-((x-m).^2 + (y-m).^2)/(2*s*s));
    g(g<eps*max(g(:))) = 0;
    g = max_z*g./max(g(:));
    
    surf(g);
    

    This way you respect the parameters of the kernel in the Gaussian lobe, but control the grid-size and resolution of the final Gaussian kernel.

    Some examples:

    enter image description here

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

Sidebar

Related Questions

I've tried to understand this post regarding this concept , however, I'm failing to
I've tried time&timertask, handler&runnables, nothing makes my function be called after certain time. Please,
I tried to understand this line of code, but it is failed. $this->request->{self::FLAG_SHOW_CONFIG} ===
I've tried to understand some of the posts of similar, but don't quite understand
I have tried to understand AOP, Dependency Injection and Inversion of Control SPRING related
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
I tried to execute this query and i can´t understand what´s wrong with it.
I have tried my best to understand a very similar StackOverflow question , but
I have tried a lot but not been able to understand the steps involved
I understand that Aptana is built from Eclipse. I tried searching for the Package

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.