Can I pcolor base on wavelength, any colormap can do so?

7 visualizzazioni (ultimi 30 giorni)
I'm tryimg to simulate diffraction pattern base on different wavelength. I can only find color map base on intensity. Is there any function or toolbox that I can change the color base on wavelength?
lambda=650e-9; % wavelength
a=10e-6; % obstruct disc radius
x=linspace(-0.2,0.2,1000);
y=x;
[X,Y]=meshgrid(x,y);
r=sqrt(X.^2+Y.^2);
% diffraction pattern
u=2.*pi.*a./lambda;
J=besselj(1,u.*sin(r));
I=(u.*((1+cos(r))./2).*(J./sin(r))).^2;
figure(1)
L=lambda.*1e9;
pcolor(X,Y,I); shading flat; axis image;
title([num2str(L)]);

Risposte (1)

Walter Roberson
Walter Roberson il 2 Dic 2020
When you pcolor(X,Y,I) then the I data will be used to decide which color information is used. By default, the numerically lowest value in I will be mapped to the first color in the color table, and the numerically largest value in I will be mapped to the last color in the color table, and all other values will be mapped according to the (value minus lowest) relative to (highest minus lowest) .
If you want the color to be based on some other information, then you should pass that other information instead of I
You currently have two independent variables (X, Y) and one dependent variable I . It looks like you intend to extend that to additional wavelengths, in which case you would have three independent variables (X, Y, wavelength) and one dependent variable. That requires a 4D plot, which are difficult to do. You could use volumeViewer with transparency to try to convey the information, but that probably will not work well. So you should consider either using slice() or using isosurface()

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by