MATLAB: Best method to define constants used by several functions

define constantMATLABmatlab function

I am implementing a model in MATLAB that relies on several functions. All of these functions are dependent on the same set of constants, which currently are defined explicitly in each function (these are all in different m-files). My aim is to run the model several times with different values for the constants, and I'm looking for an easy way to adjust these constants without having to edit all individual functions. I think this may be done using global variables or by defining named constants, but as I've never used any of these methods before I don't know which approach is best or if there is an ever better way to do it.
Edit: One of the functions must remain a single-variable function, and the constants can thus not be passed along as input parameters.

Best Answer

Change your functions to allow the constants to be passed as extra parameters, possibly as one parameter vector that can then be assigned to the individual variables in each of your functions.
I advise avoiding global variables at all costs. They can be inadvertently changed, and debugging code that uses global variables can be difficult.