필터 지우기
필터 지우기

Plotting while in a for loop doesn't work?

조회 수: 18 (최근 30일)
BrandonHeadache
BrandonHeadache 2016년 1월 24일
댓글: BrandonHeadache 2016년 1월 26일
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
Walter Roberson
Walter Roberson 2016년 1월 24일
Insufficient information about what the code contains, what operating system is in use, what MATLAB version, which NVIDIA driver you have installed.

댓글을 달려면 로그인하십시오.

채택된 답변

emehmetcik
emehmetcik 2016년 1월 24일
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.
  댓글 수: 1
BrandonHeadache
BrandonHeadache 2016년 1월 26일
Thank you! The code worked as I had wanted without 'drawnow' on my desktop, but I had the issue on my laptop and this seemed to fix it!
Thank you kindly!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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