In MATLAB, can I have a script and a function definition in the same file?
Suppose I have a function f()
and I want to use it in my_file.m
, which is a script.
- Is it possible to have the function defined in
my_file.m
? - If not, suppose I have it defined in
f.m
. How do I call it inmy_file.m
?
I read the online documentation, but it wasn't clear what is the best way to do this.