How to run a function each certain amount of time during loop?

24 ビュー (過去 30 日間)
iddqd
iddqd 2017 年 8 月 21 日
コメント済み: Jan 2017 年 8 月 23 日
I am running some kind of neurology experiment where i need to record cursor location and movements. I am doing this using infinte loop with Getmouse() inside (and also other manipulations on the cursor position) and write the position in log test file.
so far so good, the thing is that i need every few seconds to run a sync function which i already wrote (which send signal to serial port and write this event to the same log file from before).
How can i define event or interrupt in order to stop the loop every few seconds?
I am hoping i made my self clear and thanks.

回答 (1 件)

José-Luis
José-Luis 2017 年 8 月 21 日
Looks like you need a timer object inside your function.
  2 件のコメント
Jan
Jan 2017 年 8 月 23 日
Do not create the timer callback as a string, because such strings are evaluated in the base workspace, such that the change of timeout is not visible inside the function.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by