Mesh plots not captured in movie

Hi all,
I have been trying to make a movie of a changing mesh plot using VideoWriter and getframe. When running the code, the figure generated appears to be fine and is correctly animated. When I view the resulting movie, the figure seems to be blurred out with text from my work space superimposed.
First image is of what the saved movie looks like when played in VLC.
Second image is what a single frame looks like while the code is executing.
Any help would be greatly appreciated!
Other notes:
-When using pcolor instead of mesh, the same type of defective plot is generated.
-Plotting functions such as stem3, scatter3, and waterfall all produce working movies
See code below:
%%Define Function and Variables
clear, close all
clc
c_0 = 5;
D_ab = 1E-4;
num_x = 100;
num_y = 100;
num_t = 100;
t_max = 50000;
x_range = linspace(-5,5,num_x);
y_range = linspace(-5,5,num_y);
t_range = linspace(1,t_max,num_t);
c_val = zeros(num_x,num_y,num_t);
for i=1:num_x;
for j=1:num_y
for t=1:num_t
c_val(i,j,t)=(c_0/sqrt(pi*D_ab*t_range(t)))*exp(-((x_range(i).^2)+(y_range(j).^2))/(4*D_ab*t_range(t)));
end
end
end
%%Record Movie
writerObj = VideoWriter('myfirst3Dmovie.avi');
writerObj.FrameRate = 30;
open(writerObj);
for t=1:num_t
mesh(x_range,y_range,c_val(:,:,t));
xlim([-5,5])
ylim([-5,5])
zlim([0,15])
xlabel('Position-X [cm]')
ylabel('Position-Y [cm]')
zlabel('Concentration [mol / m^2 ]')
title('Diffusion of a point source over time')
frame = getframe(gcf);
writeVideo(writerObj, frame);
end
close(writerObj);

Answers (0)

Categories

Products

Asked:

on 17 May 2013

Community Treasure Hunt

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

Start Hunting!