Basically I have an m file which looks like
m
function Z=myfunc() % Do some calculations dlmwrite(\'result.out\',Z,\',\'); end
Use:
matlab -nosplash -nodesktop -logfile remoteAutocode.log -r matlabCommand
Make sure matlabCommand has an exit as its last line.
matlabCommand