Filter löschen
Filter löschen

How do I change from Square to CIrcle?

2 Ansichten (letzte 30 Tage)
Maitham
Maitham am 3 Mai 2014
Kommentiert: Dina Abd El-twab am 14 Mär. 2020
This fresnel diffraction simulation for a square aperture. I need to change it to work with a circle aperture. I need to help to change this step:
u0(257-w*20:256+w*20,257-w*20:256+w*20)=1; % setup aperture
This for a square and how i convert it to a circle?
Thank you.
The code is:
2d propagation from square apertures
ii=sqrt(-1) lambda= .365; % wavelenght [µm] z=1; % distance [µm] w=1; % width of slit is 2*w [µm]
x=-12.75:0.05:12.8; % setup spatial axis [µm] freqx=-10:20/512:10-1/512; % setup frequency axis [1/µm] freqy=freqx;
u0=zeros(512); % field at z=0 a0=zeros(512); % angular spectrum at z=0 H=zeros(512); % transfer function az=zeros(512); % angular spectrum at z=z uz=zeros(512); % field at z=z
for nx=1:512 % setup transfer function for ny=1:512 H(nx,ny)=exp(ii*2*pi*(z/lambda)*... sqrt(1-(lambda*freqx(nx))^2-(lambda*freqy(ny))^2)); end end
u0(257-w*20:256+w*20,257-w*20:256+w*20)=1; % setup aperture a0=(fftshift(fft2(u0))); % fourier transform az=a0.*H; % multiply with transfer function uz=ifft2(fftshift(az)); % inverse fourier transform p=uz.*conj(uz);
figure(1) plot(x, p(:,256)); % plot of cross-section of intensity at z xlabel('x'); ylabel('I');
figure(2) imagesc(x, x, p); %diffraction pattern at z xlabel('x'); ylabel('y'); colormap(gray); colorbar;

Akzeptierte Antwort

Image Analyst
Image Analyst am 3 Mai 2014
See code examples for creating a circle in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F. You can adapt them as needed.
  8 Kommentare
Image Analyst
Image Analyst am 14 Mär. 2020
Where is your new question (so we don't keep sending Maitham emails)? Your link above no longer works.
yellowMask = rgbImage(:,:,1) == 255 & rgbImage(:,:,2) == 255 & rgbImage(:,:,3) == 0;
yellowMask = imfill(yellowMask, 'holes');
yellowMask = bwareafilt(yellowMask, 1);
props = regionprops(yellowMask, 'Centroid', 'EquivDiameter');
viscircles(props.Centroid, props.EquivDiameter/2);
Dina Abd El-twab
Dina Abd El-twab am 14 Mär. 2020
this code didn't give me what i want ,could you please open this link , Iam gonna attach what happened in this link now to contact there

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by