I'm producing around 1000 videos in a loop with Matlab.The videos contain a 1000x1000 pixel figure with changing plots inside, initiated by
h=figure('units','pixels','Position',[0 0 1000 1000])
Each Video contains about ~20-200 frames, with each figure consisting of 5 subplots and textbox (here is an example of one frame).
Everything works fine for around 800 videos (inside a loop) when suddenly the figure size of one figure is only 1000*999 pixels. When this error happens, I tried to resize the height, but that doest work. Neither by dragging the window,nor by using the code:
set(gcf, 'Units', 'pixels','Position',[0 0 1000 1000])
But I can resize the width. Anyone know what can causes this problem?
EDIT: When i use opengl software
, everthing works fine, but the quality is by far not as good.
The basic loop (I tried to shorten as good as possible):
for i=1:length(idx) %loop over video
%Create figure and title
fh=figure('units','pixels','Position',[0 0 1000 1000])
subQ=subplot_tight(3,2,[1,2])
p_Q=plot(Q_time_num(idx_Q(i,1):idx_Q(i,2)), Q(idx_Q(i,1):idx_Q(i,2)),...
Q_time_num(idx_Q(i,1):idx_Q(i,2)), Q_trunc(idx_Q(i,1):idx_Q(i,2)),'--')
an_tit=annotation('textbox',[0.48 0.89 0.1 0.1],'String',tit_string)
set(an_tit, 'horizontalAlignment', 'center')
for i_s = 1:numel(ind) %loop over each frame
for ii=1:4length(fieldnames(Data)) %loop over the 4 subplots
if i_s==1
sub_p(ii)=subplot_tight(3,2,ii+2)
h1(ii)=plot(bord(:,2),bord(:,1),'color','k','linewidth',2,'Parent',sub_p(ii));
c(ii)=colorbar;
title([infos{ii,3},' - [',infos{ii,2},']'],'Interpreter','none')
hold on;
p(ii)=scatter(bord(cc,2),bord(cc,1),'MarkerEdgeColor',[0 0 0],...
'MarkerFaceColor',[0 0 0],'LineWidth',2,'Parent',sub_p(ii));
hold off;
end
hold on
[C,h2(ii)]=contourf(longitude,latitude,rot90(flipud(temp)),'Parent',sub_p(ii)) ;
clabel(C,h2(ii))
set(sub_p(ii),'Position',A(ii+1,:));
set(gcf, 'color', 'white');
uistack(h1(ii),'up',3)
uistack(p(ii),'up',3)
end
moving_img %save figure as frame
delete(line_Q);delete(h2(:)); delete(text_an)
end
close all
end