Functions, on the other hand, do not share the same workspace. A function won't know what a variable is unless the it gets the variable as an argument, or unless the variable is defined as a variable that is shared by the function and the matlab workspace, or a global variable.
To use a global variable, every place (function, script, or at the matlab prompt) that needs to share that variable must have a line near the top identifying it as a global variable, ie:
global phi;Then when the variable is assigned a value in one of those places, it will have a value in all the places that begin with the global statement.