whos

Lists the variables in the workspace with their size, memory and class.

Category: Language Fundamentals > Data Types

Syntax

whos

Prints a table of every variable in the current workspace.

whos name1 name2

Lists only the named variables; wildcards such as a* are allowed.

s = whos(___)

Returns a struct array with one element per variable instead of printing.

Description

whos is the long form of who. For each variable it shows the dimensions, the storage in bytes, the class, and attributes such as complex. Calling it with an output returns the same information as data, which is useful for scripts that inspect the workspace.

Inside a function the listing refers to that function's own workspace.

Input arguments

name
Variable name or pattern with * wildcards.

Output arguments

s
Struct array with fields name, size, bytes, class, global, sparse, complex, nesting and persistent.

Examples

Inspect chosen variables

x = 1:3;
y = 'hi';
z = int8([1 2; 3 4]);
whos x y z
Output
  Name      Size            Bytes  Class     Attributes

  x         1x3                24  double    
  y         1x2                 4  char      
  z         2x2                 4  int8

Get the data as a struct

a = ones(3, 4, 'single');
info = whos('a');
info.size
info.bytes
info.class
Output
ans = 1×2

     3     4
ans = 48
ans = 'single'

See also

who size class clear exist