Basically I have an m file which looks like
m
function Z=myfunc() % Do some calculations dlmwrite(\'result.out\',Z,\',\'); end
You could compile myfile into a standalone program and run that instead. Use Matlab's compiler mcc for that (if you have it), more information is provided in this question.
myfile
mcc
This answer was copied from my answer to another question.