You cannot pass a MATLAB file that requires an input argument to MATLAB in batch mode. This is not possible because when you use redirection in UNIX to pass a MATLAB file to be run in batch mode, MATLAB executes the file by reading each line as if it were typed at the MATLAB prompt. MATLAB files that require input arguments must be declared as functions, and you cannot declare a function at the MATLAB prompt.
To work around this you can create an environment variable that will contain the input argument and use the MATLAB GETENV function. For example, create the environment variable with the input argument
and retrieve the input argument using GETENV
inputArg = getenv('VAR');
inputArg = str2num(inputArg);
This will allow you to pass input arguments when using batch mode. Additionally, this can be incorporated into a shell script.
Alternatively, you can write a shell script that will take your input data file and write the necessary MATLAB file you want based on the input data file. Then, when you use redirection to run the file in batch mode, specify the name of the MATLAB file you created with your shell script.