フィルターのクリア

Spatial phase distribution is oppositely observed for imagesc and pcolor plots

13 ビュー (過去 30 日間)
Pradipta Panchadhyayee
Pradipta Panchadhyayee 2024 年 4 月 8 日
コメント済み: Pradipta Panchadhyayee 2024 年 7 月 20 日 11:26
clc;
[x,y] = meshgrid(linspace(-0.6, 0.6), linspace(-0.6, 0.6));
[phi,r] = cart2pol(x,y);
% Omega_r -vortex beam specification
l = 2;
p = 2;
w0 = 0.2;
R = sqrt(2).*r./w0;
RR = r./w0;
Omega01 = exp(-RR.^2);
Lpl = 0;
for m = 0:p;
Lpl = Lpl + (((-1).^m)./factorial(m)).*nchoosek(p+l,p-m).*(R.^(2.*m));
end;
Omega_r = Omega01.*(RR.^(abs(l))).*Lpl.*exp(-i.*l.*phi);
%figure;
%imagesc(angle(Omega_r));
%colormap jet
%colorbar
pcolor(x, y, angle(Omega_r))
shading interp
colormap jet
colorbar

回答 (1 件)

Vinayak
Vinayak 2024 年 7 月 18 日 8:35
Hi Pradipta,
The reason the two plots appear as flipped images of each other on the y-axis is due to the different default y-axis directions of 'imagesc' and 'pcolor'. For 'imagesc', the (1,1) element of the matrix is placed at the bottom-left corner of the axes by default, whereas for 'pcolor', it's placed at the top-left corner.
To make the plots similar, we can reverse the y-axis for 'imagesc' as follows:
[x, y] = meshgrid(linspace(-0.6, 0.6), linspace(-0.6, 0.6));
[phi, r] = cart2pol(x, y);
% Omega_r - vortex beam specification
l = 2;
p = 2;
w0 = 0.2;
R = sqrt(2) .* r ./ w0;
RR = r ./ w0;
Omega01 = exp(-RR.^2);
Lpl = 0;
for m = 0:p
Lpl = Lpl + (((-1).^m) ./ factorial(m)) .* nchoosek(p+l, p-m) .* (R .^ (2.*m));
end
Omega_r = Omega01 .* (RR .^ (abs(l))) .* Lpl .* exp(-1i .* l .* phi);
% Using imagesc
figure;
imagesc(x(1,:), y(:,1), angle(Omega_r)); % Ensure axes are consistent
axis xy; % Reverse y-axis direction to match pcolor
colormap jet;
colorbar;
title('imagesc');
% Using pcolor
figure;
pcolor(x, y, angle(Omega_r));
shading interp;
colormap jet;
colorbar;
title('pcolor');

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by