Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Inside the MATLAB Desktop

April 21st, 2008

Variable Editor

When the Array Editor was introduced back in MATLAB 5.0, it provided static snapshots of MATLAB double arrays.  It has evolved a lot since then, to provide dynamic editors for…

 

A lot of new functionality was added in R2008a, including

 

Because of all of these changes since Version 5, we felt that it was time to rename the Array Editor.  It’s now called the “Variable Editor” to reflect its enhanced capabilities.

 

Let’s take a look at some of the changes.  Create a variable and open it in the Variable Editor:

 

>> x = magic(10);

>> openvar x % Or go to the Workspace and double-click on x.

 

 

Here we see the Variable Editor with a new information bar bar located just below the toolbar.  It shows the name, size, and class of the current variable, as well as the same icon (based on data type) that’s shown in the Workspace.

 

We also see the new data brushing toolbar button.  Data brushing is a topic unto itself, worthy of a future posting (stay tuned - if you can’t wait to try it, checkout the documentation).

 

Structure Editing

We’ve enhanced structure editing to leverage a lot of the features that have been added to the Workspace in recent years.  To see this, let’s create a structure with some interesting data.

 

>> s.data = magic(10);

>> s.city = ‘Natick’;

>> s.temp = 70.2;

>> openvar s

 

 

As you can see, the Variable Editor shows the fields of the structure in the same way that the Workspace shows the variables in the Workspace.  Field (instead of Name), Value, Min, Max, and all of the other columns accessible in the Workspace are also shown here.  Further, all of the gestures for editing (clicks, context menus, and so on) are identical to those used in the Workspace. 

 

Object Editing

We’ve also added support for MATLAB class system objects.  Now, the public properties of objects are shown in the same way as the fields of structures.

 

Let’s examine an instance of the memmapfile object:

>> m = memmapfile(which(’clown.mat’));

>> openvar m

 

 

 

Notice that the public properties of the object appear in the Variable Editor.

 

Normally, only the public properties of an object are visible.  But if you’re debugging an object, you’ll need to be able to get to the protected or private properties, too.  The Variable Editor supports that.  Let’s set a breakpoint in one of the methods of memmapfile, and watch what happens.

 

>> edit memmapfile

Set a breakpoint on the set.writable method (in R2008a, that’s line 132) by right-clicking on that line and selecting “Set/Clear Breakpoint.”

 

Now, do something to hit that breakpoint:

>> m.writable = false;

 

The debugger stops on that line of code.  In the Editor, you can see that the object being debugged is called “obj”.  To see the contents,

>> openvar obj

 

 

The Variable Editor opens, showing all of the properties, both public and private.  The ones that end users normally have access to are shown without any lock icons next to them.  In contrast, the private properties have little red locks next to them, to show you that they’re normally inaccessible.  You can only see them because you’re debugging one of the object’s methods.

 

These enhancements to Variable Editor should help to make interactions with your data more seamless. Let us know which Variable Editor enhancement you use most!

3 Responses to “Variable Editor”

  1. chee replied on :

    Hi Bob,

    I have a question for using memmapfile.

    We can create an memmapfile object using m = memmapfile(which(’clown.mat’));

    Can we just load a subset (say the first 100 row and cols) of the matrix simply using;
    subset = m.data(1:100,1:100);?

    I tried that but it doesn’t work. Can you suggest how to access the memory mapped matlab file? Thanks.

    Chee

    Can you

  2. chee replied on :

    Hi Bob,

    The question is still about memmapfile for matlab file:

    The code is as follows:
    mydata = [(1:100)’ (1:100)’];
    save test.mat mydata -v6

    m = memmapfile(’test.mat’,'format’,{’double’,[100 2],’mydata’});
    m.Data
    ??? Error using ==> memmapfile.memmapfile>memmapfile.hCreateMap at 257

    I am wondering how to memory-map a .mat file. I guess there is some header information in the .mat file so that the data cannot be properly accessed.

  3. Bob Gilmore replied on :

    Chee,
    Sorry, but I don’t know much about MEMMAPFILE. I recommend contacting MathWorks technical support, or posting your question to the comp.soft-sys.matlab Usenet group.

    Bob Gilmore

Leave a Reply


Inside the MATLAB Desktop is written by the MATLAB Interface teams.

Team picture
  • Mike: @Daniel, What are the keyboard shortcuts you use most often? What operations do wish there were shortcuts for?
  • Biswanath Senapati: I am using MATLAB tool for our work. Now I want to integrate matlab desktop (command window) in...
  • Ken: Hi John, I can appreciate your desire for a true Mac user interface. As a Mac user myself, I am constantly...
  • John Haitas: 7 years on… still no native graphics for the Mac. When will Mathworks take time to code a GUI...
  • Ken: Hi Daniel, Your absolutely right - keyboard shortcuts in MATLAB is an area that could use some improvement. Good...
  • Daniel Armyr: Hi. I am one of those old-school people who feels that the command-line has definate merit. However,...
  • Mike: Thanks. Let us know what kinds of things you find most useful.
  • Cnenf: Thank you Michael! MATLAB and this blog has proven itself to be simply invaluable in nearly every project we...
  • Jiro: Yes, if you search the File Exchange, you’ll find SWAP, which was inspired by the file featured here:...
  • Mike: Quan, Excellent suggestion. You probably tried this, but don’t forget about searching the MATLAB File...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.

Related Topics