% updateFigureFrame

winsize = get(gcf,'Position');
winsize(1:2) = [0 0];
ff = getframe(gcf);  % get current figure frame (the top one)
ff = frame2im(ff);
[X, map] = rgb2ind(ff, 128);
imwrite(X, map, resultFigureName, 'GIF', 'WriteMode', 'append', 'DelayTime', 2);

