I just want to run my script within a certain time periodically. That's it all ....

Hi everyone, Nice to meet ya
I actually have a problem in my GUI design. My superior assign me to create a time scheduler script to create data periodically.
In the above GUI design, i want my toggle button of "Start FMI K-Indices Automation" do some work for a certain time. If the "Set Auto-Update Timer" was selected to "Per 3 Hour", so it meant my Script will run for every 00:00 AM/PM, 03:00 AM, 06:00 AM, ..... 18.00 PM, 21.00 PM, and 00 AM/PM again.
As far as i know, i just modified this script :
function [myTimer] = TimerScrip
myTimer = timer('Name','MyTimer', ...
'Period',5, ...
'StartDelay',0, ...
'TasksToExecute',inf, ...
'ExecutionMode','fixedSpacing', ...
'TimerFcn',@myTimerCallback);
start(myTimer);
function myTimerCallback(~, ~)
fprintf('hello!\n'); % This is actually filled by my actual script (FMI K-Indices) which ll create my
% data automatically for every period (00:00 AM/PM, 03:00 AM, 06:00 AM,
% ..... 18.00 PM, 21.00 PM, and 00 AM/PM)
So if everyone here, know more about the script or maybe another powerful script to run my script periodically (hopefully without "Task Scheduler") and would lend me a hand to do so, I will be happy and grateful to receive it as my solving problem... Thank youu very muchh everyoneee...

5 Comments

and what is the problem? using a timer can be the right method if you dont close matlab. you only have to set the period to 3h = 3*60*60s =10800s
Ahh, yes, Sir. You may be right. But, if i set it when the time is 01:03 AM for instance, then the next time my script run will be at 04:03 AM, 07:03 AM, etc... I want it run at exatly in 00:00 AM, 03:00 AM, 06:00 AM, etc without waiting the time to 00:00 AM/PM or 03:00 or 06:00 AM or 09:00 AM first. So even if i start the timer in 02:00 Am, then the script will automatically run in 03:00 AM, 06:00 AM, 09:00 AM continuously.
@Tyann Hardyn: What precison do you require?
@Stephen23 I have not required time precision (plus minus second or minute), Sir... Please help me, Sir .....
Do you run time-consuming tasks on MATLAB and Simulink? Do you wish you could schedule them and run them in the background, unattended? How do you solve this question today?
MATLAB Product team is very interested to talk to you and learn from your experience. Please participate in this brief survey (6 questions).

Sign in to comment.

 Accepted Answer

More Answers (1)

Do you run time-consuming tasks on MATLAB and Simulink? Do you wish you could schedule them and run them in the background, unattended? How do you solve this question today?
MATLAB Product team is very interested to talk to you and learn from your experience. Please participate in this brief survey (6 questions).

Categories

Community Treasure Hunt

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

Start Hunting!