MATLAB: How to call functions from another m file

functionsload

I have two scripts. In first script I have some functions.
script1.m:
function res = func1(a)
res = a * 5;
end
function res = func2(x)
res = x .^ 2;
end
In second script I call these functions. How to include script1.m in second script and call functions from script1.m?

Best Answer

You can't if the functions are defined as local functions in the script1 file.
Just put the functions in their own separate file (of the same name as the function and on your path) if they are being used by both script1 and script2.