From what I understood of matlab, if you want to define a function and use it in your "main file" you need to write the function in a separate file and to call it at the beginning of your "main file" with addpath('...\myfunction.m').
Now let's say I define a function f1 in a file f1.m that I use in main.m, if I want to define a function f2 (in another file) that needs to call f1, can I use addpath()...\f1.m in my f2.m file ? Or what is the best way of calling f1 in f2 ?