simulation of the electromagnetic field

3 views (last 30 days)
Bryan Wong
Bryan Wong on 12 Nov 2011
delta = 0.1;
number_of_frames = 1000;
M = moviein(number_of_frames);
for k = 1:number_of_frames,
% Coefficients
wt = k*delta;
% Component
if componenttype=='ex'
Ex_xy=((w*u_o)/h_sqr).*(modein_n.*pi/Dim_b).*...
cos(modein_m*pi*xx./Dim_a).*...
sin(modein_n*pi*yy./Dim_b).*sin((wt)-(beta.*dis_z));
[px,py] = gradient(Ex_xy,0.2,0.2);
% Clear current axes
cla;
% Quiver or velocity plot
% quiver(x,y,px,py,1);
% Create 3-D shaded surface plot
surf(x,y,Ex_xy);
shading interp;
% Capture the frame
M(:,k) = getframe;
i am currently simulating the electromagnetic wave using MATLAB. i use the command 'movie' in this simulation. My intention is to simulate the electromagnetic wave with the changing of time. Hovever, i face the following error. Can someone please suggest a solution to cope with it. Thanks in advance.
??? Error using ==> capturescreen
Figure destroyed during getframe
Error in ==> getframe at 35
x=capturescreen(varargin{:});
Error in ==> Time_field at 199
M(:,k) = getframe;

Answers (2)

Walter Roberson
Walter Roberson on 12 Nov 2011
You might want to try putting in a pause() to give getframe() time to finish its work.
  2 Comments
Bryan Wong
Bryan Wong on 12 Nov 2011
thanks for replying here....
but after i put pause(), i need to keep pressing the ENTER for 1000 times as the number_of_frame set in this program is 1000.
Bryan Wong
Bryan Wong on 12 Nov 2011
i got it already......thanks for your advice~....

Sign in to comment.


Mallikarjun Ishwargond
Mallikarjun Ishwargond on 29 Dec 2020
delta = 0.1;
number_of_frames = 1000;
M = moviein(number_of_frames);
for k = 1:number_of_frames,
% Coefficients
wt = k*delta;
% Component
if componenttype=='ex'
Ex_xy=((w*u_o)/h_sqr).*(modein_n.*pi/Dim_b).*...
cos(modein_m*pi*xx./Dim_a).*...
sin(modein_n*pi*yy./Dim_b).*sin((wt)-(beta.*dis_z));
[px,py] = gradient(Ex_xy,0.2,0.2);
% Clear current axes
cla;
% Quiver or velocity plot
% quiver(x,y,px,py,1);
% Create 3-D shaded surface plot
surf(x,y,Ex_xy);
shading interp;
% Capture the frame
M(:,k) = getframe;

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!