Did You Know that MATLAB has a Variables Window?

Did you know that MATLAB has a Variables Window? It does, though the documentation does an excellent job of not saying much about it (searching within the documentation got me nothing but a search engine got me to this helpful page). I’m guilty of giving introductory workshops without mentioning the Variables Window. I never would have talked about it until after one workshop there was a student asking a question and I opened the Variables window to help. The student thought it was very useful but they were surprised because they had never seen the window before. I assumed that this was because they were new to MATLAB.

Later, I was describing the conversation to a colleague, who was a fellow PhD student and another frequent MATLABer. I mentioned the Variables window in passing and I was stopped to explain what it was. A short survey (i.e., 2 people) showed me that this arguably fundamental feature was completely unknown in a lab where just about everyone was using MATLAB.


Ok, so what is the Variables window, anyway? The Variables window gives you a simple spreadsheet to view and edit variables. If you have the MATLAB desktop open, one of the default windows is the Workspace. The workspace lists the names of the variables stored in memory. If you double click on a variable name, then the Variables window opens for that variable. Now you can read (and modify!) the elements interactively. There is nothing unique to its functionality, since there are functions that can do all of the same tasks, but it can be more convenient. Here are some sample use cases:

  • You want to read the elements of an array that is too big to conveniently read in the console.
  • You want to read the elements of an array that has too many dimensions to conveniently read in the console.
  • You want to monitor the value of an array element while debugging code.
  • You can insert or delete rows or columns while preserving the rest of the data.

I find the Variables window handy when I’m debugging and I want to follow the changes of multiple variables. Each variable has its own tab, and you can also split the window (like the m-file editor) to view multiple variables at the same time (as I show in the screenshot above).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s