Matlab r2016b allows for functions to be embedded in scripts. I am trying to run this script, but an error occurs, and I do not know what rules I am breaking. Here is the script:
clear
clc
out=nestedvol(2)
function outvol=nestedvol(l)
outvol=2*l
end
x=4 %this line does not work.
This question continues off of In MATLAB, can I have a script and a function definition in the same file?
How could I get a script to continue after the embedded function ends? Would an anonymous function be appropriate for this?
The reason I ask this is because I make review scripts for chapters of the matlab book I am reading, so it would be nice to section areas of the code off. It seems like if any function is not included, ctrl enter does not work.