Say you have a script like this:
a <- 2
# line 3
a + a
# line 5
# line 8
2*a
# line 10
What you are asking is then in your "main" script, you need to run something between lines 3-5 or between lines 8-10. Is that correct? Or what are you trying to achieve actually?
I'm not a big user of Matlab, but it's unlikely it does something that is not possible with R (or with any other programming language, for that matter).