I would like to know how to pass lots of variables efficiently between functions.
At the moment, I have close to 30 m.files. All file are either functions or scripts. I have tried to organised my code as best as I can in groups of functions the perform as single task. Once a stage of analysis is completed, the code/evaluation moves to the next group of functions. For example,
1. Stage 1 group of functions, sub-functions and scripts: Loads data 2. Stage 2 group of funcs, subfuncs and scripts: Analyses loaded data 3. Stage 3 group of funcs, subfuncs and scripts: Generates some basic plots
I notice that passing so many variables between functions is getting tricky. For example, let's say there's a variable evaluated in Stage 1 that's useful in Stage 3. Now let's say it's evaluated in a third tier sub-function (a sub-function of a sub-function of a function), I would assign the variable out (often with "varargout"), all the way to top tier function, and then pass it all the way down to desired function in Stage 3.
My knowledge of MatLab is pretty basic, my knowledge of programming even less. So I have avoided using things like structures and callbacks. I only use scripts, functions and arrays.
Is there a better way of passing variables around between functions?