To make script accept arguments from the command line, you must first turn it into a function that will get the arguments you need, i.e. if your script has the name prog.m , put as the first line
function []=prog(arg1, arg2)
and add end to the end (assuming the file has only one function). It is very important that you call the function with the same name as the file.
The next thing you need to make sure the script file is in the same place where you are calling the script, or located on the Matlab working path, otherwise it will not be able to recognize your script.
Finally, to execute the script, you use
matlab -r "prog arg1 arg2"
which is equivalent to calling
prog(arg1,arg2)
from inside Matlab.
* - tested in Windows and Linux environments
source share