I am plotting few graphs and trying to make movie out of it. The code runs without error. But unfortunately the video is not saved. Can anyone help me on this?
a = smoothed_final_plot_mat(:,3:end);np = (size(a,2)-1)/2; % number of particles
t = a(2:end,1);arena_image = imread('arena_pic.png');h1 = axes ;image('XData',[0 6890],'YData',[0 5000],'CData',arena_image) ; % set your limits
set(h1,'YDir','normal');hold onax = gca;ax.YDir = 'reverse';axis([0 6890 0 5000])h = zeros(1,np); % ants handles
hold onwriterObj = VideoWriter('output3.avi'); % Name it.
writerObj.FrameRate = 60; % How many frames per second.
open(writerObj); for ii = 2:25:size(a,1) % frames
k = 0; t = a(ii,1); % time of current frame
str = sprintf('Time in seconds = %f', t); title(str) label = cellstr(num2str(unique(a(1,2:end))')); hold on for jj = 2:2:np*2 % ant handles
x = a(ii,jj); y = a(ii,jj+1); k = k + 1; h(k) = plot(x,y,'--or'); hi(k) = text(x, y, label(k), 'VerticalAlignment','bottom', 'HorizontalAlignment','right'); %#ok<SAGROW>
h2(k) = plot(a(max(1,ii-150):ii,jj), a(max(1,ii-150):ii,jj+1)); %#ok<SAGROW> end drawnow pause(0.00001) delete(h) delete(hi) delete(h2) hold offendframe = getframe(gcf); % 'gcf' can handle if you zoom in to take a movie.
writeVideo(writerObj, frame);close(writerObj);
Best Answer