Running a matlab script in command line (misleading .m)

The syntax to run a matlab script in batch mode from command line is:

matlab -nodesktop -nosplash -r [command]

Since I’ve accostumed to pass file name as argument to several unix tools I made some confusion on execute a script in matlab. In matlab we should pass a command, not a file name as an argument. So for run a script from command line you should first ensure that your script is in malab path (or is in your current path). Then, remember that to make a call of a Matlab script with several commands without a function you just call it by the script file name (without the .m). So if your script name is foo.m you should call as follow:

matlab -nodesktop -nosplash -r foo

See ya