Colormap limits between 0 and 1

조회 수: 1 (최근 30일)
Christopher McDwyer
Christopher McDwyer 2022년 5월 6일
댓글: Riccardo Scorretti 2022년 5월 6일
Below I have a small code which outputs an image from a simulation. The image I get will have an arbitrary axis for intensity, which I would love to have scaled to be between values of 0 and 1.
How can I achieve this?
Ex = reshape(csvread('gif240psex.td2', 23), 101, 101, []);
Ey = reshape(csvread('gif240psey.td2', 23), 101, 101, []);
pcolor(mean(abs(Ex).^2 + abs(Ey).^2, 3))
shading interp
title('VCSEL Intensity Graph')
xlabel('x-Length (μm)')
ylabel('y-Length (μm)')
colormap(jet)
colorbar

채택된 답변

Riccardo Scorretti
Riccardo Scorretti 2022년 5월 6일
I think you have to rescale the plotted quantity. That is:
val = mean(abs(Ex).^2 + abs(Ey).^2, 3);
val = val / max(val(:));
pcolor(val);
  댓글 수: 3
Christopher McDwyer
Christopher McDwyer 2022년 5월 6일
Hi Riccardo,
That suggestion worked perfectly, thank you so much!
Riccardo Scorretti
Riccardo Scorretti 2022년 5월 6일
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by