How to plot 2D Gaussian with fading
Afficher commentaires plus anciens
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?
Réponses (0)
Catégories
En savoir plus sur White dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!