필터 지우기
필터 지우기

Hi, this is my code, I want to fit 36 graphs in one graph (36 rays in layout view)

조회 수: 1 (최근 30일)
close all; clear; clc
N = 2048;
L = 1e4;
dx = 4e-3;
[x0,y0] = meshgrid((-N/2:N/2-1)*dx);
[xL,yL] = meshgrid((-N/2:N/2-1)*dx);
[fx,fy] = meshgrid((-N/2:N/2-1)/(N*dx));
Ni = 36;
xi= 1e-2 .*[-62.5,-62.5,-62.5,-62.5,-62.5,-62.5,-37.5,-37.5,-37.5,-37.5,-37.5,-37.5,...
-12.5,-12.5,-12.5,-12.5,-12.5,-12.5,12.5,12.5,12.5,12.5,12.5,12.5,37.5,37.5,37.5,37.5,37.5,37.5,...
62.5,62.5,62.5,62.5,62.5,62.5,];
yi= 1e-2 .*[62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,...
62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,];
w0 = 10e-2;
P = 1e3;
lambda = 1080e-9; k = 2*pi/lambda;
L0= 10; l0= 5e-3;
kL= 2.*pi./L0; kl= 5.92./l0;
Cn2= randi(1,60)*1e-16;
Kx = 2.*pi.*fx; Ky = 2.*pi.*fy;
U0= 0*x0;
for idx=1:Ni
U0 = U0 + sqrt(2.*P./pi)./w0 .* exp(-((x0-xi(idx)).^2+(y0-yi(idx)).^2)./w0.^2);
U0(((x0-xi(idx)).^2+(y0-yi(idx)).^2)>w0.^2) = 0;
Ui=U0;
figure(idx)
s = pcolor(x0, y0, abs(Ui));
s.EdgeColor = 'none';
title("0^{th} Intenesity screen")
xlabel 'X [m] '
ylabel 'Y [m] '
cbar = colorbar;
cbar.Label.String = 'Intensity(X, Y, 0) [W/cm^2]';
ax = gca;
axis square
ax.FontName = 'Times new roman';
ax.FontSize = 15;
end

채택된 답변

Walter Roberson
Walter Roberson 2024년 2월 21일
N = 2048;
L = 1e4;
dx = 4e-3;
[x0,y0] = meshgrid((-N/2:N/2-1)*dx);
[xL,yL] = meshgrid((-N/2:N/2-1)*dx);
[fx,fy] = meshgrid((-N/2:N/2-1)/(N*dx));
Ni = 36;
xi= 1e-2 .*[-62.5,-62.5,-62.5,-62.5,-62.5,-62.5,-37.5,-37.5,-37.5,-37.5,-37.5,-37.5,...
-12.5,-12.5,-12.5,-12.5,-12.5,-12.5,12.5,12.5,12.5,12.5,12.5,12.5,37.5,37.5,37.5,37.5,37.5,37.5,...
62.5,62.5,62.5,62.5,62.5,62.5,];
yi= 1e-2 .*[62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,...
62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,62.5,37.5,12.5,-12.5,-37.5,-62.5,];
w0 = 10e-2;
P = 1e3;
lambda = 1080e-9; k = 2*pi/lambda;
L0= 10; l0= 5e-3;
kL= 2.*pi./L0; kl= 5.92./l0;
Cn2= randi(1,60)*1e-16;
Kx = 2.*pi.*fx; Ky = 2.*pi.*fy;
U0= 0*x0;
tiledlayout('flow');
for idx=1:16; %Ni
U0 = U0 + sqrt(2.*P./pi)./w0 .* exp(-((x0-xi(idx)).^2+(y0-yi(idx)).^2)./w0.^2);
U0(((x0-xi(idx)).^2+(y0-yi(idx)).^2)>w0.^2) = 0;
Ui=U0;
nexttile();
s = pcolor(x0, y0, abs(Ui));
s.EdgeColor = 'none';
%title("0^{th} Intenesity screen")
%xlabel 'X [m] '
%ylabel 'Y [m] '
cbar = colorbar;
cbar.Label.String = 'Intensity(X, Y, 0) [W/cm^2]';
ax = gca;
axis square
ax.FontName = 'Times new roman';
ax.FontSize = 15;
end
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 3월 7일
이동: Voss 2024년 3월 7일
You did not attach an image?
mahdi
mahdi 2024년 3월 8일
In my code, I want all graphs (36) to be drawn in one color bar, not each one having a color bar.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by