hello everybody
I have this code to run a fit every 300 sec. but any time I launch it pops up over 100 figures , but I want only a figure every 300 seconds.
how to arrange it? tks
t = timer('TimerFcn', 'stat=false; disp(''Timer!'')',...
'StartDelay',300);
start(t)
stat=true;
while(stat==true)
createFit(A);
pause(1)
end

 採用された回答

Mili Goyal
Mili Goyal 2023 年 2 月 20 日

0 投票

My understanding is that you are trying to use the 'timer' function to execute a script (that plots a figure) every 300 seconds.
In order to do that, you can use the following code as a reference and implement it for your use case:
t = timer; % create a timer object
t.Period = 300; % set the period
t.TasksToExecute = 3; % Number of times the timer callback function has to be executed
t.ExecutionMode = 'fixedRate';
t.TimerFcn = @(~, ~)figure;plot(1); % I have specified a basic figure plotting function. This can be changed as per your use case.
start(t);

2 件のコメント

roberto
roberto 2023 年 2 月 20 日
編集済み: roberto 2023 年 2 月 20 日
ok it works well!
tks
roberto
roberto 2023 年 2 月 20 日
編集済み: roberto 2023 年 2 月 20 日
I'm afraid but the figure plot doesn't refresh every 300 secs.
it pops up only once and remain the same

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

タグ

質問済み:

2023 年 2 月 18 日

編集済み:

2023 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by