Time dependent programs?

18 ビュー (過去 30 日間)
Ahsan Khan
Ahsan Khan 2011 年 11 月 3 日
コメント済み: L 2021 年 10 月 22 日
is there such a method or a way i can write a program that would loop for a certain TIME instead of a certain number. for example if i want to run a program that would loop for 12 hours then stop...is this possible? thanks cheers SN

採用された回答

Jan
Jan 2011 年 11 月 3 日
iniTime = clock;
limit = 12 * 3600; % Seconds
while etime(clock, iniTime) < limit
% do the processing here
end
  2 件のコメント
Ahsan Khan
Ahsan Khan 2011 年 11 月 3 日
thanks. that seems to do the job just about right. cheers
L
L 2021 年 10 月 22 日
Hello Jan,
If I understand your code, the loop will be terminated after 12 hours?
I have another question. How can I put a time step in your code, for example the code (loop) should run every 10 minutes and it should be terminated for example after after 12 hours?
Or, maybe a better question, how can I trigger a Matlab script to start without F5 (RUN) option, process/run the code (script) every 10 minutes and terminate is after 12 hours? Is it possiible to extend your suggested code?
Thank you.

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

その他の回答 (2 件)

Kamal Zarei
Kamal Zarei 2019 年 6 月 10 日
Hi all,
Is there any way so that I can write a loop in which every iteration of that loop takes a certian time to perform?
I want to write a code with a infinite loop that every iteration of the loop takes 1 seconds to run.
Any help would be appreciated.
Best,
Kamal

Grzegorz Knor
Grzegorz Knor 2011 年 11 月 3 日

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by