How can I see a list of what global variables are defined in MATLAB? (I am using R2009a).
I have hunted unfruitfully for this on Google and SO, so apologies if it has been asked before.
Use the env command. The env command returns a list of all global variables that have been defined. If a global variable exists in a script that hasn't been run yet, it will not show up in the output from env .
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. The Details panel is not available in MATLAB Online™.
All variables in MATLAB are stored in a workspace. When manipulating data at the command line, the variables are stored in the MATLAB base workspace. The contents of this workspace can be displayed by using the whos command.
whos lists in alphabetical order the names, sizes, and types of all variables in the currently active workspace. whos -file filename lists variables in the specified MAT-file.
The WHO/WHOS commands can show you just the global variables:
who global %# Shows just the variable names
whos global %# Shows variable information, like size, class, etc.
You can also get the variable names/information returned in a variable instead of displayed on the screen:
names = who('global'); %# A cell array of variable names
data = whos('global'); %# A structure array of variable information
If you type whos
at the command line Matlab will list all currently defined variables in your workspace. The last column of output is headed 'Attributes', global variables have the attribute 'global'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With