필터 지우기
필터 지우기

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?

조회 수: 2 (최근 30일)
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

답변 (1개)

Mathieu NOE
Mathieu NOE 2024년 4월 15일
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
Pradipta Panchadhyayee
Pradipta Panchadhyayee 2024년 4월 19일
Thanks for your response. I had this kind of plot by inserting the option of number of divisions. But I was unable to change the x-axis and y-axis scalings (-0.6 to 0.6). Still this problem persists. This is not resolved.
Mathieu NOE
Mathieu NOE 2024년 4월 19일
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

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by