Before the advent of Live Script, I created a lot of demonstrations using publish and I would always create the demonstrations as functions rather than as simple scripts. This was to avoid having to use clear and close all at the beginning of the program, since entering the function allows you to create variables inside the function's own scope and publishing the code instead of running it the regular way uses entirely new figure windows.
Now I use Live Scripts to do the same thing. If the code is defined with a function command at the top line, then the "Run" button disappears from the editor. I also lose the ability to add section breaks.
My guess is the designers of MATLAB have a good reason for this, but I really miss it. Are there any workarounds?
I suppose this boils down to one question:
Is there a way, inside a live script, to use a variable scope other than the base workspace?