Run a function in given time moments.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Valeriy
am 5 Nov. 2023
Verschoben: Dyuman Joshi
am 7 Nov. 2023
Hi all
I need to run MyFunction.m tomorrow starting from 14:20:00 and repeat it 10 times with periodicity of 5 minutes. How to proceed?
Thanks for help
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 5 Nov. 2023
MATLAB does not support that.
The closest to that is that timer supports a start delay -- so you could calculate the time difference between now and 14:20 tomorrow and use that as the delay. But that is going to not going to start exactly on time -- and if you exit MATLAB in the meantime then the timer will not run, and will not start up again if you go back into MATLAB.
3 Kommentare
Walter Roberson
am 5 Nov. 2023
I would suggest writing a control table to a file indicating the date/time when each event is to start.
Then, periodically:
- read the file
- schedule a timer object (using relative time) for any event that is due to start within the next two refresh cycles; if there is already a timer for the event, check to see whether the start time delay needs to be updated
This scheduling should also be done upon starting MATLAB
Creation of a new event should be accompanied by writing the event to the control file and then running the check cycle again.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!