It might help you to learn about global variable declarations. Do "help global" inside Matlab. Write a script called declare_globals and inside it, declare all the global variables you need to use, such as currents and pyramids. Then include a call to declare_globals at the beginning of every script or function you write. This way you won't have to pass things like currents as a parameter; you can set them up in one function and reference them in another. Note: do not put all the current definitions and other parameter values inside declare_globals; you don't want that code running repeatedly in you model's inner loop. Your variables should be initialized in a separate script that runs only once. Only "global" statements go in the declare_globals file. Of course, if you did everything as scripts instead of functions, you wouldn't have to bother declaring anything global. But the drawback of that approaach is that you really do want some things to take arguments, e.g., updatePyramid should take an argument indicating which pyramidal cell to update. Only functions can take arguments; scripts cannot. So you're forced to use functions to keep your code clean. And that's why you should use globals: so you can have clean code but not have to pass major data structures as parameters.