- Create a MATLAB Script: Save your MATLAB code in a .m file, e.g., myScript.m:
- Create a Batch File: Create a .bat file (e.g., run_matlab_script.bat) to run the script in MATLAB:
- Replace R2023a with your MATLAB version.
- Replace C:\path\to\myScript.m with the full path to your script.
- Schedule with Windows Task Scheduler:
- Open Task Scheduler (search for it in Windows).
- Click Create Task (not Basic Task for daily scheduling).
- General Tab:
- Name the task (e.g., "Run MATLAB Daily").
- Check "Run whether user is logged on or not" for reliability.
- Triggers Tab:
- Click New → Set trigger to Daily at 6:00 PM.
- Ensure "Enabled" is checked.
- Actions Tab:
- Click New → Action: Start a Program.
- Browse to your .bat file (e.g., C:\path\to\run_matlab_script.bat).
- Conditions/Settings:
- Optional: Set conditions like "Start only if computer is on AC power."
- Save the task, entering your user credentials if prompted.
- Test:
- Right-click the task in Task Scheduler and select Run to verify it executes correctly.
1 2 3 | disp('Running my daily task at 6 PM!'); % Your code here exit; % Close MATLAB after execution |
1 | "C:\Program Files\MATLAB\R2023a\bin\matlab.exe" -batch "run('C:\path\to\myScript.m')" |