who

Returns the names of variables defined in the current session of the application.

Syntax

who

who(pattern)

R = who('global')

R = who(pattern, 'global')

Inputs

pattern
Type: string

Outputs

R
If assigned to the result of who, R will be a cell array of strings whose elements are the names of the variables defined in the current session of the application.
Type: cell of strings

Examples

Lists both local and global variables:

localVariable1 = 247;
testLocalVariable = 'Sample';
global globalVariable2;
who
Variables in current scope:
globalVariable2
localVariable1
testLocalVariable
Lists global variables only, with output assigned to R:
localVariable1 = 247;
testLocalVariable = 'Sample';
global globalVariable2;
R = who('global')
R =
{
[1,1] globalVariable2
}
Lists global and local variables, matching the given pattern:
localVariable1 = 247;
localtest = 'Sample';
global globalVariable2;
who('*ble*')
Variables in current scope:
globalVariable2
localVariable1
Lists global variables matching the given pattern:
localVariable1 = 247;
localtest = 'Sample';
global globalVariable2;
who('*ble*', 'global')
Variables in current scope:
globalVariable2

Comments

If an optional second argument, pattern, is passed, only the variables matching the pattern are returned. If the optional argument global is passed, only global variables are included in the scope of the lookup for the who function. If the who function is not assigned to any variable, the output will have a comment about the variables in the current scope. Otherwise, the result R will be displayed as a cell array of strings whose elements are the names of the variables in the current session.