In MATLAB, can I have a script and a function definition in the same file?
Asked 07 September, 2021
Viewed 470 times
  • 64
Votes

Suppose I have a function f() and I want to use it in my_file.m, which is a script.

  1. Is it possible to have the function defined in my_file.m?
  2. If not, suppose I have it defined in f.m. How do I call it in my_file.m?

I read the online documentation, but it wasn't clear what is the best way to do this.

7 Answer