Clear Filters
Clear Filters

Plot an Gaussian function..

2 views (last 30 days)
Lizan
Lizan on 23 Oct 2012
Hi, I am trying to plot a 2D/3D plot of a Gaussian function but I am having some issues. I don't see a Gaussian.. anyone that can help?
Example:
X_pixel = 2500; Y_pixel = 2000;
A = 100;
x0 = X_pixel/2;
y0 = Y_pixel/2;
sigma_x = 25e-6;
sigma_y = 0.5e-6;
for theta = 1:pi/4:pi
disp('plot')
[X, Y] = meshgrid(0:1:(X_pixel), 0:1:(Y_pixel));
Z = A*exp( - (((X-x0).^2)/(2*(sigma_x^2)))) - (((Y-y0).^2)/(2*(sigma_y^2)))) ;
figure
surf(X,Y,Z);
colormap(cool)
shading interp;
colorbar
%view(90,90);
axis equal;
drawnow
end

Accepted Answer

Image Analyst
Image Analyst on 23 Oct 2012
Your parentheses in Z are messed up (not matching) and your sigmas (100^-6) are way way too small to be seen for x going from 0-2500. Try something like 500 or so.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!