MATLAB Function Reference Previous page   Next Page
who, whos

List variables in workspace

Graphical Interface

As an alternative to whos, use the Workspace browser. Or use the Current Directory browser to view the contents of MAT-files without loading them.

Syntax

Each of these syntaxes apply to both who and whos:

Description

who lists the variables currently in the workspace.

whos lists the current variables and their sizes and types. It also reports the totals for sizes.

who(variable_list) and whos(variable_list) list only those variables specified in variable_list, where variable_list is a comma-delimited list of quoted strings: 'var1', 'var2', ..., 'varN'. You can use the wildcard character * to display variables that match a pattern. For example, who('A*') finds all variables in the current workspace that start with A.

who(variable_list, qualifiers) and whos(variable_list, qualifiers) list those variables in variable_list that meet all qualifications specified in qualifiers. You can specify any or all of the following qualifiers, and in any order.

Qualifier Syntax
Description
Example
'global'
List variables in the global workspace.
whos('global')
'-file', filename
List variables in the specified MAT-file. Use the full path for filename.
whos('-file', 'mydata')

'-regexp', exprlist

List variables that match any of the regular expressions in exprlist.
whos('-regexp', '[AB].', '\w\d')

s = who(variable_list, qualifiers) returns cell array s containing the names of the variables specified in variable_list that meet the conditions specified in qualifiers.

s = whos(variable_list, qualifiers) returns structure s containing the following fields for the variables specified in variable_list that meet the conditions specified in qualifiers:

who variable_list qualifiers and whos variable_list qualifiers are the unquoted forms of the syntax. Both variable_list and qualifiers are space-delimited lists of unquoted strings.

Remarks

Information returned by the command whos -file is independent of whether the data in that file is compressed or not. The byte counts returned by this command represent the number of bytes data occupies in the MATLAB workspace, and not in the file the data was saved to. See the function reference for save for more information on data compression.

Examples

Show variable names starting with the letter a:

Show variables stored in MAT-file mydata.mat that start with java and end with Array. Also show their dimensions and class name:

Get variable names that start with uppercase or lowercase X, are followed by zero or more other characters, and end with at least two digits. Assign the output to cell array xvars:

See Also

assignin, clear, computer, dir, evalin, exist, inmem, load, save, what, workspace


Previous page  whitebg wilkinson Next page

© 1994-2005 The MathWorks, Inc.