Passing an argument from command line to Matlab script can be tricky because There are two solutions I can think of right now: Set the environment variables before starting Matlab Using BASH shell, one may set the environment variable using the command: a=1;b=2 Start Matlab using the command: matlab -nojvm -nosplash Inside matlab script one can get those variables using the command: a=getenv(a); b=getenv(b). Using the argument "-r" matlab -nojvm -nosplash -r "a=1;b=2; aScriptName;"