| Contents | Index |
who
who(variables)
who(location)
who(variables,location)
c = who(variables,location)
who lists in alphabetical order all variables in the currently active workspace.
who(variables) lists only the specified variables.
who(location) lists variables in the specified location: 'global' for the global workspace, or '-file' for a MAT-file. For MAT-files, you must also include the file name as an input.
who(variables,location) lists the specified variables in the specified location. The location input can appear before or after variables.
c = who(variables,location) stores the names of the variables in cell array c. Specifying variables and location is optional.
The who function displays the variable list unless you specify an output argument.
When used within a nested function, the who function lists the variables in the workspaces of that function and all functions containing that function, grouped by workspace. This applies whether you call who from your function code or from the MATLAB debugger.
variables |
Strings that specify the variables to list. Use one of these forms:
Default: '*' (all variables) | ||||
location |
String that indicates whether to list variables from the global workspace or from a file:
Default: '' (current workspace) |
c |
Cell array of strings that correspond to each variable name. |
Display information about variables in the current workspace whose names start with the letter a:
who a*
Show variables stored in MAT-file durer.mat:
who -file durer
This code returns:
Your variables are: X caption map
Store the variable names from durer.mat in cell array durerInfo:
durerInfo = who('-file', 'durer');Display the contents of cell array durerInfo:
for k=1:length(durerInfo)
disp(durerInfo{k})
endThis code returns:
X caption map
Suppose that a file mydata.mat contains variables with names that start with java and end with Array. Display information about those variables:
whos -file mydata -regexp \<java.*Array\>
Call who within a nested function (get_date):
function who_demo
date_time = datestr(now);
[str pos] = textscan(date_time, '%s%s%s', ...
1, 'delimiter', '- :');
get_date(str);
function get_date(d)
day = d{1};
mon = d{2};
year = d{3};
who
end
endWhen you run who_demo, the who function displays the variables by function workspace (although the name of the function does not appear in the output):
Your variables are: d mon ans pos day year date_time str
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.
assignin | clear | dir | evalin | exist | inmem | load | save | what | whos | workspace

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |