global

Declares a list of variables as global. When a variable is declared as global it may be accessed within a function without being passed as a parameter. Variables must be declared as global in both the scope they are defined and the scope they are used.

Syntax

global x

Inputs

x
A variable name to be declared as global.
Type: string
Dimension: string

Example

Global example.

global z
z=4

function b=foo(a)
  global z
  b=z+a;
end

foo(3)
z = 4
ans = 7