MATLAB: Can a new function be defined in the middle of livescript

livescriptMATLAB

Can one define a function in the middle of LiveScript or does it have to be at the end of the script?

Best Answer

No.
%%
a=1;
function out=timestwo(in)
out=in*2;
end
b=timestwo(a)
Error: File: Untitled Line: 8 Column: 1
Function definitions in a script must appear at the end of the file.
Move all statements after the "timestwo" function definition to before the first local function
definition.