Spatial phase distribution is oppositely observed for imagesc and pcolor plots
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Vinayak
il 18 Lug 2024
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');
Vedere anche
Categorie
Scopri di più su Orange 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!