I tried to define and use a simple matlab/octave function within an org-mode code block as shown follows.
#+name: test-octave-function
#+begin_src octave
function s = my_sum(x, y)
s = x + y;
end
my_sum(1, 2)
#+end_src
The code works if put inside a .m
file. However, in a code-block, it generates this error in Org-babel output:
warning: function name 'my_sum' does not agree with function filename ''
error: 'my_sum' undefined near line 1 column 1
I understand functions defined for use in other files need to have the same name as the .m file. But how do filenames work for a code block. Also, I called the function my_sum
in the same code block, why is it undefined?
Related to this, how can I define and use multiple functions in a code block?
(This is with the stock Emacs 26 of Ubuntu 20.04)