Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

who

List variables in workspace

Syntax

Description

example

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

example

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

who global lists the variable names in the global workspace.

example

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

example

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

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

Examples

collapse all

Display Workspace Variable Names

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 Names of Variables in a MAT-File

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

who -file durer.mat
Your variables are:

X        caption  map      

Store Variable List in Cell Array

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)
   disp(C{k})
end
X
caption
map

List Workspace Variables Within Nested or Anonymous Function

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);
 
date_time_array = strsplit(date_time,{'-',''});
get_date(date_time_array);

   function get_date(d)
      day = d{1};
      mon = d{2};
      year = d{3};
      keyboard
   end

end
K>> 

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

who_demo

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 — Variables to displaycharacter vectors

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

Form of Variables InputVariable Names
var1 ... varNList the variable names, specified as individual character vectors.
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. For example, who -regexp ^Mon ^Tues lists only the variables names in the workspace that begin with Mon or Tues.

filename — Name of MAT-filecharacter vector

Name of MAT-file, specified as a character vector. 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.

Output Arguments

collapse all

C — List of variablescell array of character vector

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

Alternatives

  • 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

Was this topic helpful?