10. Other Commands

global

Often a variable (which could be a scalar variable, or an array, or a symbolic variable representing a mathematical expression) has been determined in one M-file and might also be needed in another M-file, for example a function M-file. However, it might not be practical or possible to pass it across as an input variable to the function. Two M-files can share a common Matlab workspace for a variable var if the command

global var

occurs in both M-files before it is defined or used in either.