What is drawnow doing?

8 次查看(过去 30 天)
Alessandro Masullo
Alessandro Masullo 2015-11-13
Hello everyone.
I'm working on a code where I need to alternate the display of two complex plots in a very short time. The time for creating each plot is quite high (4-5 seconds) and I want to alternate them with a lag of 0.1 seconds. Creating a new plot every 0.1 seconds is therefore completely useless.
My idea was to create the two plots in two different axes and alternate the visibility of them. The problem is that drawnow keeps taking a very long time just to show one axes instead of the other.
Is there any way I can speed up this process?
Example of code:
figure
x1 = rand(100000,1);
y1 = rand(100000,1);
x2 = rand(100000,1);
y2 = rand(100000,1);
t = tic;
delay = 0.5;
flag = 0;
while 1
if toc(t) > delay
if flag
plot(x1,y1,'.')
flag = 0;
else
plot(x2,y2,'.')
flag = 1;
end
drawnow
end
end

回答(1 个)

Walter Roberson
Walter Roberson 2015-11-13
编辑:Walter Roberson 2015-11-14
figure
x1 = rand(100000,1);
y1 = rand(100000,1);
x2 = rand(100000,1);
y2 = rand(100000,1);
p1 = plot(x1,y1,'.', 'visible', 'off');
p2 = plot(x2,y2,'.', 'visible', 'off');
t = tic;
delay = 0.5;
flag = 0;
while 1
if toc(t) > delay
if flag
set(p2, 'visible', 'off');
set(p1, 'visible', 'on');
flag = 0;
else
set(p1, 'visible', 'off');
set(p2, 'visible', 'on');
flag = 1;
end
drawnow
end
end
  9 个评论
Mike Garrity
Mike Garrity 2015-11-17
It's really not an answer yet. We need to figure out why you are getting softwareopengl. There are a couple of reasons this might happen. Two common reasons.
  1. We have a blacklist for some drivers we've seen a lot of problems with.
  2. The system that reports crashes back to us looks at the call stack. If the crash was in your graphics card driver, we'll set your default to softwareopengl to prevent it happening again.
Could you start MATLAB with the -hardwareopengl switch and then do opengl info again? That's probably the easiest way to get all of the details about your graphics card. I'll see if I can find someone who can help figure out what's going on. Hopefully it'll be as simple as updating your driver to a different version.
Alessandro Masullo
Alessandro Masullo 2015-11-18
Someone suggested me to set opengl to software many months ago, because of a bug that I was experiencing with surf.
I don't remember the exact post, but it was something like this issue: http://www.mathworks.com/matlabcentral/answers/52943-mesh-or-surf-display-problem-on-windows-7
It happened on a previous version of matlab. So far I haven't experienced the bug on the R2015a.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by