Add the following to your ~/.vimrc file and you'll have the option of running a script from within your editor of choice; ViM!
This tries to mimic the actual use of the F5 key in Matlab Desktop, so feel free to change it something more handly. My choice is < leader >r, where the < leader > is the ','.
map <leader>r :w<CR>:!/Applications/MATLAB_R2012a_Student.app/bin/matlab -nodesktop -nosplash -r "try, run %:p, pause, catch, end, quit" <CR> <CR>
You would probably need to change the
< /MATLAB_R2012a_Student.app/ >
part to what your version of Matlab is. I should say that this should also work in Linux by simply changing the path, but I haven't tried it.