Plotting while in a for loop doesn't work?
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
BrandonHeadache
el 24 de En. de 2016
Comentada: BrandonHeadache
el 26 de En. de 2016
Hi Everyone,
I'm running a particle simulation code that is supposed to visualize the particles in each iteration of a for loop. Basically show the motion of the particles throughout the time set specified. The issue is that the figures are just gray boxes until the loop is over.
This only seems to be an issue on my laptop that has a Nvidia Quadro Card, I think this might be the reason but any ideas why this might be the case?
Thanks kindly, Brandon
1 comentario
Walter Roberson
el 24 de En. de 2016
Insufficient information about what the code contains, what operating system is in use, what MATLAB version, which NVIDIA driver you have installed.
Respuesta aceptada
emehmetcik
el 24 de En. de 2016
A solution for this problem is "drawnow" function, assuming that your code is something like this :
for k = 1 : N
% Your code here, calculating "x"
plot(x);
% drawnow;
end
If "drawnow" was not used, Matlab accumulates all the plots in loops and draws them all at once after the execution of your script.
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!