MATLAB: How to referrence a value (matrix) from script file to a function file

cross referrence from function file to script file

I have a function file that has a subroutine.
When I run the subroutine I want to then reference a value from the script file when running the function file.
eg.
val = 5 (in script file)
that script file runs the function file
said function file then references val from the script file.

Best Answer

The point of functions is to have their own scope and workspace so you pass in the things you need as input arguments.
If you script runs your function then it can just pass the relevant value down to the function as an argument.