1 year ago

#381679

test-img

ui su Cho

Showing multiple EMwave grahp with imagesc in Matlab

I want to show multiple graph of EMwave point source. But when I run this code, it show just one EMwave. How can I show multiple graphs? and How can I show the surf graph at the same time. without error. Here is the code. Thank you for Answer. ''' clear all; %작업 공간 변수 초기화 close all; %Figure 초기화 clc; %명령 창 초기화

%% 변수 정의
nm = 1e-9;
beta = 0;
lambda = 650*nm;% wavelength of red light
k = 2*pi/lambda;
c0 = 2.99e8;    % speed of light
w  = k*c0;

%% 좌표 정의
x = linspace(-20*lambda,20*lambda,500);   
y = linspace(-20*lambda,20*lambda,500);
z = beta*lambda;
[xx, yy] = meshgrid(x,y); % two-dimensional map of x,y  

%% 전기장 기술 discribe EM wave
Ex0 = 1e-6; %Absolute amplitude
rr1 = sqrt(xx.^2 + (yy-(10*lambda)).^2 + z.^2);
Ex_phasor1 = (Ex0./rr1).*exp(j*(-k*rr1));
rr2 = sqrt((xx-(10*lambda)*cos(pi/3)).^2 + (yy-(10*lambda)*sin(pi/3)).^2 + z.^2);
Ex_phasor2 = (Ex0./rr2).*exp(j*(-k*rr2));
rr3 = sqrt((xx-(10*lambda)*cos(2*pi/3)).^2 + (yy-(10*lambda)*sin(2*pi/3)).^2 + z.^2);
Ex_phasor3 = (Ex0./rr3).*exp(j*(-k*rr3));
rr4 = sqrt((xx-(10*lambda)*cos(pi)).^2 + (yy-(10*lambda)*sin(pi)).^2 + z.^2);
Ex_phasor4 = (Ex0./rr4).*exp(j*(-k*rr4));
rr5 = sqrt((xx-(10*lambda)*cos(4*pi/3)).^2 + (yy-(10*lambda)*sin(4*pi/3)).^2 + z.^2);
Ex_phasor5 = (Ex0./rr5).*exp(j*(-k*rr5));
rr6 = sqrt((xx-(10*lambda)*cos(5*pi/3)).^2 + (yy-(10*lambda)*sin(5*pi/3)).^2 + z.^2);
Ex_phasor6 = (Ex0./rr6).*exp(j*(-k*rr6));

%% 동영상 재생 및 저장 - imagesc
v = VideoWriter('EMnL_design_1_2.avi'); 
v.FrameRate = 15; open(v); 
dt = 2*pi/w/10;

for t = 0:dt:100*dt
figure(1)
imagesc(x,y,real(Ex_phasor1*exp(j*w*t)) );
hold on
imagesc(x,y,real(Ex_phasor2*exp(j*w*t)) );

imagesc(x,y,real(Ex_phasor3*exp(j*w*t)) );

imagesc(x,y,real(Ex_phasor4*exp(j*w*t)) );

imagesc(x,y,real(Ex_phasor5*exp(j*w*t)) );

imagesc(x,y,real(Ex_phasor6*exp(j*w*t)) );
hold off
colormap jet; axis xy;
caxis([-1 1]);

frame = getframe(gcf);
writeVideo(v,frame);
end
 close(v);
 %% 동영상 재생 및 저장 - surf
% v = VideoWriter('EMnL_design_1_2_surf.avi'); 
% v.FrameRate = 15; open(v); 
% dt = 2*pi/w/10;
% 
% for t = 0:dt:100*dt
% figure(2)
% s1 = surf(x,y,real(Ex_phasor1*exp(j*w*t)));
% s2 = surf(x,y,real(Ex_phasor2*exp(j*w*t)));
% s3 = surf(x,y,real(Ex_phasor3*exp(j*w*t)));
% s4 = surf(x,y,real(Ex_phasor4*exp(j*w*t)));
% s5 = surf(x,y,real(Ex_phasor5*exp(j*w*t)));
% s6 = surf(x,y,real(Ex_phasor6*exp(j*w*t)));
% colormap jet; axis xy;
% s.EdgeColor = 'none'; caxis([-1 1]);
% axis([y(1) y(end) x(1) y(end) -2 2]);
% 
% frame = getframe(gcf);
% writeVideo(v,frame);
% end
%  close(v);

'''

matlab

matlab-figure

0 Answers

Your Answer

Accepted video resources