matlab - 如何控制 pcolor 图中的颜色和强度?
问题描述
我正在尝试模拟 Coronae(液滴的衍射)。颜色取决于波长,强度取决于衍射。如何通过波长 ( lambda ) 和强度 ( I ) 同时控制颜色?我现在只能控制 lambda 以获得不同颜色的衍射图案。
lambda=400; % wavelength [nm]
a=10e3; % obstruct disc radius [nm](um)
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=sqrt((u.*((1+cos(r))./2).*(J./sin(r))).^2); % Intensity
% colormap
w=lambda;
if (w >= 380) && (w < 440)
R = -(w - 440.) / (440. - 380.);
G = 0.0;
B = 1.0;
elseif (w >= 440) && (w < 490)
R = 0.0;
G = (w - 440.) / (490. - 440.);
B = 1.0;
elseif (w >= 490) && (w < 510)
R = 0.0;
G = 1.0;
B = -(w - 510.) / (510. - 490.);
elseif (w >= 510) && (w < 580)
R = (w - 510.) / (580. - 510.);
G = 1.0;
B = 0.0;
elseif (w >= 580) && (w < 645)
R = 1.0;
G = -(w - 645.) / (645. - 580.);
B = 0.0;
elseif (w >= 645) && (w <= 780)
R = 1.0;
G = 0.0;
B = 0.0;
else
R = 0.0;
G = 0.0;
B = 0.0;
end
c=[R,G,B];
h=linspace(0,1,256); % illumination (intensity) from [0,1]
for i=1:length(h)
S{i}=h(i).*c;
end
map=cell2mat(S');
% figure
pcolor(X,Y,I); shading flat; axis image; title([num2str(lambda)]);
colormap(map);
解决方案
推荐阅读
- docker - Dockerfile 不会安装 cron
- android - 运行 flutter build appbundle 时的问题 | 无法确定任务“:app:transformClassesAndResourcesWithR8ForRelease”的依赖关系
- python - Discord.py 在嵌入消息中发送 youtube 缩略图
- fasttext - 为什么fastText的文本分类示例没有在标签上应用LabelEncoder
- go - Go 模板 - 范围的语法
- r - 在没有 NA 的情况下按组计算平均值
- swift - 如何在 Swift 中传递多个符合单个协议的泛型参数
- sql - 如何将多个值传递给 sys.objects 表中的“SCHEMA_ID”
- c++ - 使用头文件编译时对对象的未定义引用
- memory-leaks - 为什么 Netty ByteBuf.readBytes 会导致内存泄漏?