Can sections be skipped with something similar to "return" or "continue"?
52 views (last 30 days)
In MatLab live scripts one can split the code into sections. This may be for a visual overview and also allows for running just a specific section at a time instead of the entire code.
I would like to ask if this sectioning is more than visual and practical but also recognizable by the code itself - can the code e.g. treat a section in the same manner as, say, a loop or a function? If so, can a section be skipped by a command similar to what commands such as return or continue do?
So, the question in short is: Is there a way to skip an entire section if a condition is met? Something like:
if ~toggle; _skip this section_; end
Skipping the rest of a function or loop is easy with e.g.:
if ~toggle; return; end
and I am looking for this similar feature for skipping a section. I am asking if this is possible before wrapping an entire section in an if-statement.
Jared MacDonald on 4 May 2020
There is currently no way to skip a section other than writing a conditional. This is an intriguing suggestion, though, and we've made a note of it.