Basically I have an m file which looks like
m
function Z=myfunc() % Do some calculations dlmwrite(\'result.out\',Z,\',\'); end
nohup matlab -nodisplay -nodesktop -nojvm -nosplash -r script.m > output &