use Matlab cell mode:

percent percent space starts a new cell,
each cell can be evaluated on its own.
http://blogs.mathworks.com/community/2009/06/08/using-the-cell-mode-toolbar/