Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

how to avoid the complex result when using ifft2

6 Ansichten (letzte 30 Tage)
Donyau Chiang
Donyau Chiang am 24 Jun. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
How are you? I tried to solve an optical intensity distribution problem, based on the theory derived from Prof. J.W. Goodman and Prof. M. Mansuripur. My code is below: % calculate the intensity pattern for the x- and z- polarized light at a distance % of z=20 from a aperture of radius r0=3, the original polarized being x
close all; clear all;
r0=3.; nod=256; L=10*r0; z0=20.; det=L/nod; du=1/L;
xyp=(-nod/2:nod/2-1)*det; [xp,yp]=meshgrid(xyp,xyp);
% create a circle of radius r0=3 vn1=find(sqrt(xp.*xp+yp.*yp) <= r0); t1=zeros(nod,nod); t1(vn1)=ones(size(vn1));
uv=(-nod/2:nod/2-1)*du; [u,v]=meshgrid(uv,uv); vn2=find(sqrt(u.*u+v.*v) <= 1); A1=zeros(nod,nod); A1(vn2)=ones(size(vn2));
% do the FFT for circle aperture T1=fftshift(fft2(t1)); T1=T1.*A1;
sgz=sqrt(ones(nod)-u.*u-v.*v);
% create x-polarized component fxx fxx=(ones(nod)+sgz-u.*u)./((ones(nod)+sgz).*sqrt(sgz)); gt=exp(i*2*pi*z0*sgz); ta=((T1.*fxx).*gt); tb=ifft2(ta); Ta=tb.*conj(tb);
mesh(xp,yp,Ta)
% create z-polarized component fxz fxz=-u./sqrt(sgz); tc=((T1.*fxz).*gt); tc=ifft2(tc); Tb=tc.*conj(tc);
figure mesh(xp,yp,Tb)
I get the error message from MatLab as: Error using ==> surface X, Y, Z, and C cannot be complex.
But if I use L=100*r0, I can get the result. Could someone teach me the restriction to use ifft2 command? Your help will be great appreciated. With best Regard Donyau

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by