如何加快matlab的"打印"功能

jer*_*rad 2 printing matlab user-interface save figure

我在matlab中编写了一个相当大的数据采集程序,它在非常紧凑的时序安排上接收输入数据,并在GUI上实时绘制.我的问题是我需要一种方法让程序用户通过Web查看GUI以远程监控他们的数据.我的解决方案是每隔5秒左右快速拍摄一下GUI图形,并将该图像托管在Web服务器上.

然而,这导致两个不可接受的问题:

  1. 打印功能太慢了 - 每次保存需要大约3-4秒,程序随后在每次调用"打印"后落入其他例程.

  2. 由于某种原因,打印功能会导致GUI暂时失真,更改某些组件的位置并复制其他组件.它持续一秒左右,但它仍然使我的解决方案不切实际.

有没有办法解决这些问题?

编辑:*** 对于任何感兴趣的人,我发现的最佳解决方案是使用名为Minicap的外部工具包.

Ric*_*ton 7

文件格式有很大的不同.这是一个示例散点图

n = 1e4;
hfig = figure;
hax = plot(1:n, rand(1, n), '+');
Run Code Online (Sandbox Code Playgroud)

...以及保存到不同格式的一些时间.

tic; print(hfig, 'test.bmp', '-dbmp'); toc      %4.1s
tic; print(hfig, 'test.bmp', '-dbmp256'); toc   %2.0s
tic; print(hfig, 'test.png', '-dpng'); toc      %1.9s
tic; print(hfig, 'test.tiff', '-dtiff'); toc    %0.45s
tic; print(hfig, 'test.jpg', '-djpeg'); toc     %0.44s
tic; print(hfig, 'test.wmf', '-dmeta'); toc     %0.42s
Run Code Online (Sandbox Code Playgroud)

tiff,jpeg并且wmf是并列第一,虽然TIFF文件是巨大的,JPEG质量糟糕和WMF有问题,如果你不是在Windows平台上.


对于栅格格式,分辨率也会影响时序.

tic; print(hfig, 'test600.png', '-dpng', '-r600'); toc   %4.2s
tic; print(hfig, 'test72.png', '-dpng', '-r72'); toc     %0.31s
Run Code Online (Sandbox Code Playgroud)

加快打印速度的另一个方法是删除不需要的绘图.透明度在计算上是密集的,传说也是如此.对数据进行采样而不是全部绘制将节省时间.