A little late to the game, but might still be useful to you or others. I doubt you can do this from within matlab. Others with more experience may suggest otherwise. I would split the two tasks into separate matlab programs and use the -sync option with Grid Engine:
qsub -sync y do_task_1.sh
# -sync y makes qsub wait for job to finish
qsub do_task_2.sh
You can put the above commands in a script so you don't have to wait for first task to complete.
Alternatively, you can use '-hold_jobid`:
qsub do_task_1.sh
qsub -hold_jid <job_id_of_task_1> do_task_2.sh