{"id":209,"date":"2008-04-21T06:39:11","date_gmt":"2008-04-21T11:39:11","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2008\/04\/21\/variable-editor\/"},"modified":"2016-08-16T14:23:25","modified_gmt":"2016-08-16T18:23:25","slug":"variable-editor","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2008\/04\/21\/variable-editor\/","title":{"rendered":"Variable Editor"},"content":{"rendered":"<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">When the Array Editor was introduced back in MATLAB 5.0, it provided static snapshots of MATLAB double arrays.\u00a0 It has evolved a lot since then, to provide dynamic editors for&#8230;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&nbsp;<\/p>\n<ul>\n<li>One- and two-d arrays of all <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f2-12135.html\">numeric types<\/a><\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f2-97022.html\"> Logical arrays<\/a><\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f2-67323.html\"> Cell Arrays<\/a><\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f2-88951.html\"> Structures<\/a><\/li>\n<li>Single-line <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f2-47856.html\"> character arrays<\/a><\/li>\n<li><a href=https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f2-41105.html\"> timeseries objects<\/a><\/li>\n<li>viewers for all other objects, including N-D arrays.<\/li>\n<\/ul>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">A lot of new functionality was added in R2008a, including<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&nbsp;<\/p>\n<ul>\n<li>Editors for objects created in the new <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_oop\/ug_intropage.html&#038;https:\/\/www.mathworks.com\/products\/matlab\/object_oriented_programming.html\"> MATLAB class system<\/a><\/li>\n<li>Improved Structure support<\/li>\n<li>Support for Data Brushing<\/li>\n<li>Other interface enhancements.<\/li>\n<\/ul>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Because of all of these changes since Version 5, we felt that it was time to rename the Array Editor.\u00a0 It&#8217;s now called the &#8220;Variable Editor&#8221; to reflect its enhanced capabilities.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Let&#8217;s take a look at some of the changes.\u00a0 Create a variable and open it in the Variable Editor:<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; x = magic(10);<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; openvar x % Or go to the Workspace and double-click on x.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">\n<div align=\"center\"><img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/bob_gilmore_editing_variables\/VEMagic10.png\"><\/a><\/div>\n<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Here we see the Variable Editor with a new information bar bar located just below the toolbar.\u00a0 It shows the name, size, and class of the current variable, as well as the same icon (based on data type) that&#8217;s shown in the Workspace.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">We also see the new data brushing toolbar button.\u00a0 Data brushing is a topic unto itself, worthy of a future posting (stay tuned &#8211; if you can&#8217;t wait to try it, checkout the <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/learn_matlab\/bq45say-1.html\">documentation<\/a>).<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\"><b>Structure Editing<\/b><\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">We&#8217;ve enhanced structure editing to leverage a lot of the features that have been added to the Workspace in recent years.\u00a0 To see this, let&#8217;s create a structure with some interesting data.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; s.data = magic(10);<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; s.city = &#8216;Natick&#8217;;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; s.temp = 70.2;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; openvar s<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">\n<div align=\"center\"><img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/bob_gilmore_editing_variables\/VEStructure.png\"><\/a><\/div>\n<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">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.\u00a0 Field (instead of Name), Value, Min, Max, and all of the other columns accessible in the Workspace are also shown here.\u00a0 Further, all of the gestures for editing (clicks, context menus, and so on) are identical to those used in the Workspace.\u00a0<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\"><b>Object Editing<\/b><\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">We&#8217;ve also added support for MATLAB class system objects.\u00a0 Now, the public properties of objects are shown in the same way as the fields of structures.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Let&#8217;s examine an instance of the <tt><a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/ref\/memmapfile.html\"> memmapfile<\/a><\/tt> object:<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; m = memmapfile(which(&#8216;clown.mat&#8217;));<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; openvar m<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">\n<div align=\"center\"><img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/bob_gilmore_editing_variables\/VEMemmap.png\"><\/a><\/div>\n<p>\u00a0<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Notice that the public properties of the object appear in the Variable Editor.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Normally, only the public properties of an object are visible.\u00a0 But if you&#8217;re debugging an object, you&#8217;ll need to be able to get to the protected or private properties, too.\u00a0 The Variable Editor supports that.\u00a0 Let&#8217;s set a breakpoint in one of the methods of <tt>memmapfile<\/tt>, and watch what happens.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; edit memmapfile<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Set a breakpoint on the set.writable method (in R2008a, that&#8217;s line 132) by right-clicking on that line and selecting &#8220;Set\/Clear Breakpoint.&#8221; <\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">Now, do something to hit that breakpoint:<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; m.writable = false;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">The debugger stops on that line of code.\u00a0 In the Editor, you can see that the object being debugged is called &#8220;obj&#8221;.\u00a0 To see the contents,<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">&gt;&gt; openvar obj<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">\n<div align=\"center\"><img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/bob_gilmore_editing_variables\/VEMemmapDebug.png\"><\/a><\/div>\n<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">The Variable Editor opens, showing all of the properties, both public and private.\u00a0 The ones that end users normally have access to are shown without any lock icons next to them.\u00a0 In contrast, the private properties have little red locks next to them, to show you that they&#8217;re normally inaccessible.\u00a0 You can only see them because you&#8217;re debugging one of the object&#8217;s methods.<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; min-height: 14px; margin: 0px\">&nbsp;<\/p>\n<p style=\"font: normal normal normal 12px\/normal Helvetica; margin: 0px\">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!<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When the Array Editor was introduced back in MATLAB 5.0, it provided static snapshots of MATLAB double arrays.\u00a0 It has evolved a lot since then, to provide dynamic editors for&#8230;<br \/>\n&nbsp;<\/p>\n<p>One- and&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2008\/04\/21\/variable-editor\/\">read more >><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/209"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=209"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":4008,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/209\/revisions\/4008"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}