How to plot 2D Gaussian with fading
이전 댓글 표시
I would like to plot the cross-section of a Gaussian beam in a 2D plane, which has the following intensity profile: I = exp(-2*(x^2+y^2)/w00^2), where x and y are distances from the central axis. I want the centre of the Gaussian (with the highest intensity) to be plotted in some specific color (ideally light orange or red) and this color should continuously fade to white as the distance from the centre increases.
My code so far:
w00 = 1;
x = linspace(-2*w00,2*w00,10000);
y = linspace(-2*w00,2*w00,10000);
[X,Y] = meshgrid(x,y);
intensity = exp(-2 * (X.^2 + Y.^2) / w00^2);
figure
image(intensity,'CDataMapping','scaled')
The problem is that I can't figure out how to change the color scheme in the image command in such a way that the centre is yellow, which slowly fades towards white. Also, how can I make sure that the colour transitions are as smooth as possible so that there are no visible boundaries between different colours?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!