Overview
I am using the MATLAB kernel in Jupyter Notebook. I would like to write a function in the notebook, rather than referring to a function that is saved in another .m
file. The problem is that when I try to do so, I get the error:
Error: Function definitions are not permitted in this context.
Visual example:
In a new notebook, it looks like the following picture:
Now, it does work if I make a new .m
file:
and then call then function via the notebook:
but this is inconvenient. Is there a way to define functions from within a Jupyter Notebook directly?
My software
- MATLAB 2017b
- Windows 10
- Jupyter running in chrome
- Jupyter installed via anaconda
eval
, which doesn't accept function definitions. For example, if you tryeval('function trialcode() asdf = 1; end')
in MATLAB you'll receive the same error. – excazaeval
has done it again! – buzjwaEEEEVAAAAAALLLLL!!!
– Mateen Ulhaq