{"id":432,"date":"2010-11-29T18:56:50","date_gmt":"2010-11-29T18:56:50","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2010\/11\/29\/enumeration-templates\/"},"modified":"2010-11-29T18:56:50","modified_gmt":"2010-11-29T18:56:50","slug":"enumeration-templates","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2010\/11\/29\/enumeration-templates\/","title":{"rendered":"Enumeration Templates"},"content":{"rendered":"<p>Ever since Class Objects were first introduced in R2008a, we&#8217;ve improved or added to their functionality. In R2010b, we have official support for Enumerations. <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/matlab_oop\/bsibelu.html\">Enumerations<\/a> are type-safe collections of discrete, named values. Classic textbook examples are the days of the week (Monday, Tuesday, etc) and months (January, February, etc), because they represent a simple, complete set. <\/p>\n<p>There are some similarities between MATLAB enumerations and those in other languages. You can use enumerations in set operations, comparisons, string expressions, switch\/case statements. Like in Java, enumerations are themselves classes so you can add methods and customize their behavior. In C, enumerations are represented by <tt>int<\/tt>s, which means there is an implicit ordering. In MATLAB enumerations can subclass numeric types and thus have an ordering, but they don&#8217;t have to. Although enumerations can subclass other data types, they themselves cannot be sub-classed. <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/simulink\/ug\/bspsfem.html\">Simulink enumerations<\/a> are MATLAB enumerations that are subclasses of Simulink.IntEnumType.<\/p>\n<p>How does the Desktop support enumerations? Because enumerations are class objects, they are supported out-of-the-box with features like M-Lint, file preview, and tab completion. One new enumeration-specific feature is the Enumeration Template that can be reached from File -> New -> Enumeration. <\/p>\n<div align=\"center\">\n<img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/michael_katz_enumerations\/newenumeration.png\" alt=\"How to make a new enumeration\">\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Ever since Class Objects were first introduced in R2008a, we&#8217;ve improved or added to their functionality. In R2010b, we have official support for Enumerations. Enumerations are type-safe&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2010\/11\/29\/enumeration-templates\/\">read more >><\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,69],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/432"}],"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\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}