This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


List variables in workspace


who -file filename
who global
who ___ variables
C = who(___)



who lists in alphabetical order the names of all variables in the currently active workspace.


who -file filename lists the variable names in the specified MAT-file.

who global lists the variable names in the global workspace.


who ___ variables lists only the specified variables. You can specify variables with any of the arguments in the previous syntaxes.


C = who(___) stores the names of the variables in the cell array C.


You must use the functional form of who when there is an output argument.


collapse all

List the names of variables in the current workspace that start with the letter a.

who a*

Display the names of variables in the current workspace that end with ion.

who -regexp ion$

List the names of variables stored in the sample MAT-file durer.mat.

who -file durer.mat
Your variables are:

X        caption  map      

Store the list of variable names in durer.mat in cell array C.

C = who('-file','durer.mat');

Display the contents of C.

for k=1:length(C)

List all the variable names in the current workspace while paused in a nested function.

Create a file who_demo.m, that contains these statements.

function who_demo
date_time = datestr(now,'dd-mmm-yyyy');
date_time_array = strsplit(date_time,{'-',''});

   function get_date(d)
      day = d{1};  %#ok<*NASGU>
      mon = d{2}; 
      year = d{3}; 


Run who_demo. MATLAB® pauses at the line with the keyboard command.


Call the who function. MATLAB displays the names of the variables in the nested get_date function and in all functions containing the nested function.

K>> who
Your variables are:

d                mon              date_time        
day              year             date_time_array  

Input Arguments

collapse all

Variables to display, specified as one or more character vectors or string scalars in one of these forms.

Form of Variables InputVariable Names
var1 ... varNList the variable names, specified as individual character vectors or string scalars.
Use the '*' wildcard to match patterns. For example, who A* lists the names of all the variables in the workspace that start with A.
-regexp expr1 ... exprNList only the variable names that match the regular expressions, specified as character vectors or string scalars. For example, who -regexp ^Mon ^Tues lists only the variables names in the workspace that begin with Mon or Tues.

Data Types: char | string

Name of MAT-file, specified as a character vector or string scalar. The file name can include the full, relative, or partial path. For example, who -file myFile.mat lists the names of all variables in the MAT-file named myFile.mat.

Data Types: char | string

Output Arguments

collapse all

List of variables, specified as a cell array of character vector.


  • To view the variables in the workspace, use the Workspace browser. To view the contents of MAT-files, use the Details Panel of the Current Folder browser.

Introduced before R2006a