Ken & Mike on 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!

8 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

  4. Marcelino Martinez replied on :

    Hi,

    I am using varible editor in order to check the values in a big array (more than 280000 rows)

    Is it possible to jump to a specific row or colum in variable editor ?

    Thank you very much

  5. Bob Gilmore replied on :

    Marcelino,
    Sorry, but that capability isn’t available yet. We have it entered in our enhancement tracking system.

    Thanks for asking,

    Bob Gilmore

  6. Daniel replied on :

    Hi,

    I use Matlab R2008b, but I cannot see the private members of the obj I’m debugging. Are there any additional settings to be made in order to make them visible in the variable editor?

    Daniel

  7. Ryan replied on :

    Hi,

    I find the variable editor very useful now that it is possible to view my own objects. There seems to be a problem using dependent properties however. It seems that if I have more than a couple of them, none of my objects properties show in the Variable Editor anymore. Is there a way around this? I cannot find any documentation to suggest what I am doing wrong.

  8. Mike replied on :

    Ryan,

    There shouldn’t be a limit to the number of dependent properties that can be displayed (other than maybe system resources). Since this occurs for you at some variable point, I would suggest first talking to technical support to see if they can recommend a workaround:
    http://www.mathworks.com/support/service_requests/contact_support.do

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Ken & Mike work on the MATLAB Desktop team.
  • DP: Hi i have a problem with ezplot3, i want to plot more than i curve in the same graph but hold on command...
  • Ken: Hi Arsalan, Unfortunately there is no way to get the new Editor API in older versions of MATLAB. -Ken
  • Arsalan: Hi, I am very excited about the MATLAB API for editor because right now i am working on a project and i need...
  • Johannes: Since I started using matlab-emacs some days ago I never experienced Emacslink. But I experienced some...
  • Francisco J. Beron-Vera: Hi all, I have recently learned about ViEmu (http://www.vimemu.c om) which, for Vi/Vim...
  • OysterEngineer: When I first learned of the Publish feature in MatLab, I thought it might be useful to help to...
  • Ken: Hi Herve, I’m not quite sure what you mean by “stand-alone&# 8221; mode? -Ken
  • Herve: I wonder when the publish fonction will be supported in standalone mode.
  • Mike: Ravi, What you described should work as far I understand it. Please follow up with technical support. With a...
  • Mike: @Daniel, Thanks for that note.

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