MATLAB: I cannot define a function in live script

functionlivescriptscript

Hi,
I tried to define a function in LiveScript but as soon as I add it to a script it freezes the "Run" button.
However, while writing normal script that NOT happened.
Does anyone have an answer for that? I will appreciate it.

Best Answer

It clearly mentioned in the documentation below:
https://www.mathworks.com/help/matlab/matlab_prog/local-functions-in-scripts.html#bvclt99 - make sure the function is at the end if the file and the codes above it.