Thread Subject: Animation timer

Subject: Animation timer

From: Peter Bone

Date: 30 Apr, 2008 16:36:03

Message: 1 of 3

I want to update a figure plot every 30th of a second to
create an animation with accurate update periods. I can't
simply use pause(1/30) because updating the figure takes
time (although less than 1/30 s) and so it would update
slower than I want so I do the following (with some
pseudo-code):

initialise_parameters;
tic
for i = 1 : 1000
  draw_plot;
  text(10,10,int2str(floor(i/30)))
  drawnow
  pause(1/30 - toc)
  tic
  update_parameters;
end

The text shows the seconds updating so that I can see the
update rate.
This works better but it updates slightly too fast by
approximately 4 seconds per minute.

Does anyone know why this is and is there a better way to
create an accurate animation timer?

Peter Bone

Subject: Animation timer

From: Scott Hirsch

Date: 1 May, 2008 13:47:02

Message: 2 of 3

>> help timer

I posted a simple example on the File Exchange:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8452&objectType=FILE

Note that the submission references a corresponding News &
Notes Article. This article ended up not being published,
but you should be able to get what you need from the example
code.

- scott

Subject: Animation timer

From: Scott Hirsch

Date: 1 May, 2008 13:50:06

Message: 3 of 3

Never mind my last comment - we published the article a year
later than originally planned:

http://www.mathworks.com/company/newsletters/news_notes/oct06/tips.html

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
animation Scott Hirsch 1 May, 2008 09:50:12
timer Scott Hirsch 1 May, 2008 09:50:12
timer animation pause Peter Bone 30 Apr, 2008 12:40:22
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com