【发布时间】:2016-07-21 16:48:53
【问题描述】:
条件:如果循环运行没有停顿,颜色条不会占图片的 50% 左右;如果我设置断点并逐步运行,所有颜色条都会出现;我认为这是一些稳定性/内存问题
伪代码
i=1;
while (i < 3);
figure('Visible', 'off');
hax=axes();
image('Parent',hax);
% Do heavy computation here; see the warning below for it.
a=rand(1,20000);
b=rand(1,20000);
C=rand(20000,20000);
imagesc(a,b,C);
colorbar(hax)
%% Unsuccessful attempts
%drawnow % does not help
%pause(1) % does not help
homedir=char(java.lang.System.getProperty('user.home')); % all systems
filename=fullfile(home, sprintf('/Desktop/%d', i));
export_fig(filename, '-png', '-q101', '-a1', '-m1', ...
'-CMYK', '-nocrop', '-dpng', hax);
i=i+1;
end
颜色条消失后的错误消息,表示内存问题
Warning: print2array generating a 46.1M pixel image.
This could be slow and might also cause memory
problems.
- 苏弗。
colorbar之后的命令drawnow没有帮助。
系统:Linux Ubuntu 16.04 64 位
Matlab:2016a
硬件:Macbook Air 2013-mid
【问题讨论】:
-
在您致电
colorbar后添加drawnow。问题是如果没有暂停,渲染器就没有时间将颜色条实际绘制到屏幕上。 -
给我们一个minimal reproducible example,它实际上证明了这个问题。除非您真的只想显示默认的
image,否则编写的代码是无法运行的。 -
您似乎忘记使用实际代码编辑问题。我们不想要伪代码,因为它不会重现问题。
-
在创建图像和颜色条时尝试指定明确的轴
-
再次向我们展示实际代码。您提供的代码没有任何内存问题。