Clear Filters
Clear Filters

How can I change this code to use it for a Circular aperture instead of the Rectangle Aperture?Thank you

2 views (last 30 days)
How can I use the circ instead of the rect below?
% sqr_beam propagation example
L1=0.5*10^-3; %side length
M=256; %number of samples
dx1=L1/M; %src sample interval
x1=-L1/2:dx1:L1/2-dx1; %src coords
y1=x1;
lambda=0.5*10^-6; %wavelength
k=2*pi/lambda; %wavenumber
w=0.051*10^-3; %source half width (m)
z=10.0*10^-4; %propagation dist (m)
[X1,Y1]=meshgrid(x1,y1);
u1=rect(X1/(2*w)).*rect(Y1/(2*w)); %src field
I1=abs(u1.^2); %src irradiance
figure(1)
imagesc(x1,y1,I1);
axis square; axis xy;
colormap('gray'); xlabel('x (m)'); ylabel('y (m)');
title('z= 0 m');
u2=propIR(u1,L1,lambda,z); %propagation
x2=x1; %obs coords
y2=y1;
I2=abs(u2.^2); %obs irrad
figure(2) %display obs irrad
imagesc(x2,y2,I2);
axis square; axis xy;
colormap('gray'); xlabel('x (m)'); ylabel('y (m)');
title(['z= ',num2str(z),' m']);
%
figure(3) %irradiance profile
plot(x2,I2(M/2+1,:));
xlabel('x (m)'); ylabel('Irradiance');
title(['z= ',num2str(z),' m']);
%
figure(4) %plot obs field mag
plot(x2,abs(u2(M/2+1,:)));
xlabel('x (m)'); ylabel('Magnitude');
title(['z= ',num2str(z),' m']);
%
figure(5) %plot obs field phase
plot(x2,unwrap(angle(u2(M/2+1,:))));
xlabel('x (m)'); ylabel('Phase (rad)');
title(['z= ',num2str(z),' m']);
************************************** I have a function for a circle but how can I iclude it in the code above? the circle function is:
function my_circ(imageSize, center,radius)
%UNTITLED Summary of this function goes here % Detailed explanation goes here imageSizeX=imageSize(1); imageSizeY=imageSize(2); [columnsInImage rowsInImage]=meshgrid(1:imageSizeX,1:imageSizeY); centerX=center(1); centerY=center(2); circlepixels=(rowsInImage - centerY).^2+(columnsInImage - centerX).^2<=radius.^2; image(circlepixels); colormap([0 0 0;1 1 1]); title('Binary image of a circle');
end

Answers (0)

Categories

Find more on Fuzzy Logic Toolbox 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!