how to perform for loop;
조회 수: 1 (최근 30일)
이전 댓글 표시
dim=64;
[kx,ky]=meshgrid(-1:2/(dim-1):1);
circ=sqrt(kx.^2+ky.^2)<1;
kx=kx/2;
ky=ky/2;
alp=asin(0.8);
k0=1/sin(alp);
k=256;
kz=sqrt(k0^2-(kx.^2+ky.^2));
Gx=sqrt(k0./kz).*((k0*ky.^2+kz.*kx.^2)./(k0*(kx.^2+ky.^2)));
Gy=sqrt(k0./kz).*((kz-k0).*kx.*ky)./(k0*(kx.^2+ky.^2));
Gz=sqrt(k0./kz).*(kx./k0);
z=-64:1:63;
[r,c]=size(z);
mz=pi*64/(256);
Ex=zeros([k,k,c]);
Ey=zeros([k,k,c]);
Ez=zeros([k,k,c]);
for jj=1:c
Ex(:,:,jj)=fftshift(fft2(exp(1i*kz*z(jj)*mz).*Gx.*circ,k,k));
Ey(:,:,jj)=fftshift(fft2(exp(1i*kz*z(jj)*mz).*Gy.*circ,k,k));
Ez(:,:,jj)=fftshift(fft2(exp(1i*kz*z(jj)*mz).*Gz.*circ,k,k));
end
I =Ex.*conj(Ex)+Ey.*conj(Ey)+Ez.*conj(Ez);
M=I(k/2,:,:);
M1=squeeze(M).';
figure(1)
imagesc((M1));colormap gray
I have problem to perform for loop operation, I used above method to perform
for loop operation. Can anyone help me to perform this for loop operation in
other method it will be great helpfor me
thanking you in advance for your kind help
댓글 수: 1
per isakson
2012년 12월 5일
Your script runs here (R2012a, 64bit, Windows7) and produces an image. I cannot see any problem.
Do you get a warning or error message? You need to be more specific.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!