フィルターのクリア

timer with varying periods

6 ビュー (過去 30 日間)
Mihai
Mihai 2012 年 12 月 18 日
回答済み: Martin Grden 2020 年 10 月 7 日
Hi all!
I am running a test setup where I need to take measurements at varying intervals that are between the values of 47 < T < 53 seconds.
By this I mean, the period between executions of TimerFcn is not a constant value, rather a random value between 47 and 53.
Do you guys know if this is possible with the timer function?
I checked the 'Period' property of Timer(), and it takes a double value, not a function.
This is how I have my code set up right now.
getMeasurementsTimer = timer();
set(getMeasurementsTimer, 'executionmode', 'fixedRate', 'period', data);
set(getMeasurementsTimer, 'StartFcn', {'startTest', hObject});
set(getMeasurementsTimer, 'TimerFcn', {'getTemp', hObject});
  3 件のコメント
Daniel Shub
Daniel Shub 2012 年 12 月 19 日
There currently is not enough information to answer this question. Please edit the question and reopen.
Mihai
Mihai 2012 年 12 月 19 日
編集済み: Mihai 2012 年 12 月 19 日
By varying interval i mean a dynamic value for the "period" property. So between execution one and two it could be 49.555 seconds, and the next time the function is executed is 52.111 seconds later.
One of the requirements is that the difference between the max Tr (period between measurements)and min Tr has to be at least 4 seconds.

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

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 12 月 19 日
I don't know of this being possible, but it is certainly a good idea for an enhancement request.
Here is how I would tackle this:
  1. Have the timer only execute once, i.e. 'TasksToExecute' = 1.
  2. In the 'TimerFcn' have it start a new timer with a StartDelay equivalent to your new period.
  3. Finally at the end of the 'TimerFcn', have it delete the timer calling it so you don't end up with hundreds of timers
  2 件のコメント
Dan
Dan 2017 年 5 月 15 日
Would be nice to be able to dynamically change the timer period 'on the fly' ...
desire is 'fixed rate' timer within the callback of which I'd like to modify the period to be used for the current period. While changing the period of the current interval is desired, changing the period of the next interval would be acceptable.
In lieu of this enhancement, I'll have to use the 'startat' feature to restart the timer at the appropriate time given the time passed to the callback in the current callback.
Amira chriki
Amira chriki 2020 年 4 月 16 日
Can you please give me more details about how to change the timer's period inside the same timer timerFcn?

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

その他の回答 (1 件)

Martin Grden
Martin Grden 2020 年 10 月 7 日
TimerFcn(objh,event)
...
% at the end of your TimerFcn:
stop(opjh);
opjh.Period=newPeriod;
opjh.StartDelay=newPeriod;
start(opjh);

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by