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 wan't have to pass things like currents as a parameter; you can set them up in one function and reference them in another. 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.