In order to schedule a task in Windows Operating System prior to Windows7, that executes a MATLAB file, do the following:
1. Click on Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks -> Add Scheduled Task
2. Choose MATLAB.
3. After you finish setting up the scheduled task, open the task Properties.
4. If there is
specified under "Run:", change it to:
D:\MATLAB.exe -r mfile [-logfile c:\logfile]
mfile is the name of the MATLAB file you want to execute. If you use the option -logfile, then everything that would be outputted to the MATLAB command window will be saved here. You can also put multiple commands there. For example:
D:\MATLAB.exe -r cd('C:\'),mytest,exit -logfile c:\logfile
would change the current directory to C:\ (where the MATLAB file mytest.m lives), run mytest.m and exit MATLAB. The command window output will be saved in C:\logfile.
To schedule MATLAB script on Windows 7 Task Scheduler, perform the following steps:
1) In Task Scheduler, click on "Create Task".
2) Set the Name and Trigger time.
3) In the Actions tab, click "New". The "Action" should be kept as "Start a program".
4) For "Program/script", use "Browse..." to find the MATLAB executable, which should be a value like: "<file:///C:/Program C:\Program> Files\MATLAB\R2011b\bin\matlab.exe".
5) Set arguments to: -r scriptname;quit. It is not required to specify the ‘.m’ extension here.
6) Set the "Start in" value as the directory containing the script file, e.g.:<file:///C:/users/username/Desktop/Folder. C:\users\username\Desktop\Folder.>