Plot an Gaussian function..
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Annotations 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!