How can I get more divisions in x- and y- axes scaling when plotting with imagesc to have a clear picture and introduce the proper scaling along x- & y- axes?
1 view (last 30 days)
Show older comments
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
Answers (1)
Mathieu NOE
on 15 Apr 2024
hello
simply specify the number of points when you call linspace
here I introduced N = 500 (N = 100 by default)
N = 500;
[x,y] = meshgrid(linspace(-0.6, 0.6 ,N), linspace(-0.6, 0.6 ,N));
[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);
figure;
imagesc(angle(Omega_r));
colormap jet
colorbar
axis square
2 Comments
Mathieu NOE
on 19 Apr 2024
try this
you need to create x and y vectors (before the meshgrid call) - that will be used latter as arguments to pass to imagesc
now your axes are displayed with -0.6 / + 0.6 range
N = 500;
x = linspace(-0.6, 0.6 ,N);
y = linspace(-0.6, 0.6 ,N);
[X,Y] = meshgrid(x,y);
[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);
figure;
imagesc(x,y,angle(Omega_r));
colormap jet
colorbar
axis square
See Also
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!