필터 지우기
필터 지우기

How we can display images at different times by using for loop instead of following program and how we can make movie from following program?

조회 수: 3 (최근 30일)
  1. clear all;
  2. clc;
  3. close all;
  4. dim=32;
  5. [kx,ky]=meshgrid(-3:6/(dim-1):3);
  6. circ=sqrt(kx.^2+ky.^2)<1;
  7. r=sqrt(kx.^2+ky.^2);
  8. alp=asin(0.95);
  9. k0=1/sin(alp);
  10. k=256;
  11. kz=sqrt(k0^2-(kx.^2+ky.^2));
  12. Gx=-1i*sqrt(k0./kz).*((k0*ky.^2+kz.*kx.^2)./(k0*(kx.^2+ky.^2)));
  13. Gy=1i*sqrt(k0./kz).*((kz-k0).*kx.*ky)./(k0*(kx.^2+ky.^2));
  14. Gz=1i*sqrt(k0./kz).*(kx./k0);
  15. Fx=1i*sqrt(k0./kz).*((kz-k0).*kx.*ky)./(k0*(kx.^2+ky.^2));
  16. Fy=-1i*sqrt(k0./kz).*((k0*kx.^2+kz.*ky.^2)./(k0*(kx.^2+ky.^2)));
  17. Fz=1i*sqrt(k0./kz).*(ky./k0);
  18. ph=(atan2(kx,ky)+pi);
  19. ph=rot90(ph,3);
  20. la=-sin(ph);
  21. lb=rot90(cos(ph),3);
  22. z=-128:1:127;
  23. c = numel(z);
  24. mz=(pi/(3*8*2*tan(alp/2)));
  25. n = size(kx);
  26. Ex = zeros([k k c]);
  27. Ey = zeros([k k c]);
  28. Ez = zeros([k k c]);
  29. for jj=1:c
  30. Ex(:,:,jj)=fftshift(fft2(exp(1i*kz*mz*z(jj)).*(Gx.*la.*circ)-rot90(exp(1i*kz*mz*z(jj)).*Gy.*lb.*circ,3),k,k));
  31. Ey(:,:,jj)=fftshift(fft2(exp(1i*kz*mz*z(jj)).*(Gy.*la.*circ)+rot90(exp(1i*kz*mz*z(jj)).*Gx.*lb.*circ,3),k,k));
  32. Ez(:,:,jj)=fftshift(fft2(exp(1i*kz*mz*z(jj)).*(Gz.*la.*circ)+rot90(exp(1i*kz*mz*z(jj)).*Gz.*lb.*circ,3),k,k));
  33. end
  34. Ex=Ex(k/2,:,:);
  35. Ey=Ey(k/2,:,:);
  36. Ez=Ez(k/2,:,:);
  37. Ex=squeeze(Ex);
  38. Ey=squeeze(Ey);
  39. Ez=squeeze(Ez);
  40. Ix=Ex.*conj(Ex);
  41. Iy=Ey.*conj(Ey);
  42. Iz=Ez.*conj(Ez);
  43. I=Ix+Iy+Iz;
  44. t=0;
  45. I1=((I).*exp(1i*pi*t));
  46. t=(2/7);
  47. I2=((I).*exp(1i*pi*t));
  48. t=(2*2/7);
  49. I3=((I).*exp(1i*pi*t));
  50. t=(3*2/7);
  51. I4=((I).*exp(1i*pi*t));
  52. t=(4*2/7);
  53. I5=((I).*exp(1i*pi*t));
  54. t=(5*2/7);
  55. I6=((I).*exp(1i*pi*t));
  56. t=(6*2/7);
  57. I7=((I).*exp(1i*pi*t));
  58. t=7*2/7;
  59. I8=((I).*exp(1i*pi*t));
  60. figure(7)
  61. subplot(2,4,1);imagesc(I1.*conj(I1)),colormap gray;axis image;axis off
  62. subplot(2,4,2);imagesc(I2.*conj(I2)),colormap gray;axis image;axis off
  63. subplot(2,4,3);imagesc(I3.*conj(I3)),colormap gray;axis image;axis off
  64. subplot(2,4,4);imagesc(I4.*conj(I4)),colormap gray;axis image;axis off
  65. subplot(2,4,5);imagesc(I5.*conj(I5)),colormap gray;axis image;axis off
  66. subplot(2,4,6);imagesc(I6.*conj(I6)),colormap gray;axis image;axis off
  67. subplot(2,4,7);imagesc(I7.*conj(I7)),colormap gray;axis image;axis off
  68. subplot(2,4,8);imagesc(I8.*conj(I8)),colormap gray;axis image;axis o
  69. % % movie(F(t))
# I what to two display time dependence image of I by using for loop and how we can make movie from this time dependence of I.
# how we get all images at all times;
# by using for loop t=0:2/7:2;
# if anyone help me in this regard it is great help for me
# thanks in advance,
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 4월 3일
Those decimal numbers at the beginning of every line are going to cause syntax errors.
Image Analyst
Image Analyst 2013년 4월 3일
Yeah, makes it so much of a pain to fix that I'm not even going to attempt to copy and paste this into MATLAB. I suggest the author read this tutorial on how to put code in so that we can copy and paste it, as well as read it: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup

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

답변 (1개)

Image Analyst
Image Analyst 2013년 4월 3일
I can't run your code, so all I can suggest is the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_create_a_movie_from_my_MATLAB_figures.3F and to put in a "drawnow" in the loop to force it to update/refresh the display immediately instead of waiting until it gets around to it or finishes the loop.

카테고리

Help CenterFile Exchange에서 Sudoku에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by