{"id":300,"date":"2008-08-20T10:23:56","date_gmt":"2008-08-20T15:23:56","guid":{"rendered":"https:\/\/blogs.mathworks.com\/videos\/2008\/08\/20\/advanced-matlab-dynamic-field-names\/"},"modified":"2016-04-04T15:26:00","modified_gmt":"2016-04-04T20:26:00","slug":"advanced-matlab-dynamic-field-names","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/videos\/2008\/08\/20\/advanced-matlab-dynamic-field-names\/","title":{"rendered":"Advanced MATLAB: Dynamic field names"},"content":{"rendered":"We have MATLAB users come into The MathWorks to present their work in MATLAB from time to time. Recently there was an interesting presentation with some really great &#8220;Clutter classification&#8221; algorithms in a GUI. One of the questions that came out of that discussion was how to get rid of a bunch of EVAL statements from their code. The following code shows how they can be avoided using &#8220;dot parens notation&#8221;, or Dynamic Field Names as they are formally known.\r\n\r\na.doug = &#8216;Hull&#8217;\r\na.jiro = &#8216;Doke&#8217;\r\n\r\nname = &#8216;doug&#8217;;\r\n\r\nlast = a.doug\r\neval([&#8216;last = a.&#8217; name]) %BAD\r\nlast = a.(name) %GOOD\r\n<div><div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"3877438015001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div><\/div>\r\n&nbsp;","protected":false},"excerpt":{"rendered":"<div class=\"thumbnail thumbnail_asset asset_overlay video\"><a href=\"https:\/\/blogs.mathworks.com\/videos\/2008\/08\/20\/advanced-matlab-dynamic-field-names\/?dir=autoplay\"><img decoding=\"async\" src=\"https:\/\/cf-images.us-east-1.prod.boltdns.net\/v1\/static\/62009828001\/7d1674a4-f95e-43ca-892b-e0fbbb5ce3f3\/db417d8a-91e3-42ab-893e-c2371ef3a0ea\/160x90\/match\/image.jpg\" onError=\"this.style.display ='none';\"\/>\n      <div class=\"overlay_container\">\n      <span class=\"icon-video icon_color_null\"><time class=\"video_length\">1:59<\/time><\/span>\n      <\/div>\n      <\/a><\/div><p>We have MATLAB users come into The MathWorks to present their work in MATLAB from time to time. Recently there was an interesting presentation with some really great &#8220;Clutter&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/videos\/2008\/08\/20\/advanced-matlab-dynamic-field-names\/\">read more >><\/a><\/p>","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,4,12],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/300"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":2159,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/300\/revisions\/2159"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}