in MATLAB
» mcc -m myfunction.m
create a script:
#!/bin/sh
module load matlab
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pkg/matlab/7.14_r2012a/runtime/glnxa64:/pkg/matlab/7.14_r2012a/sys/java/jre/glnxa64/jre/lib/amd64/server/
export XAPPLRESDIR=/pkg/matlab/7.14_r2012a/X11/app-defaults/
ABSPATH/myfunction $1 $2 > $3
module load sge
qsub -q ttn.q ABSPATH/myfunction.sh hello world ABSPATH/output.txt
Where ABSPATH should be replaced with the absolute path of each file (e.g. /home/fowlkes). Absolute paths should be used everywhere since qsub doesn't run in the same cwd.