{"id":261,"date":"2008-09-22T09:04:16","date_gmt":"2008-09-22T14:04:16","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2008\/09\/22\/matlab-pragmas\/"},"modified":"2016-04-04T10:03:47","modified_gmt":"2016-04-04T14:03:47","slug":"matlab-pragmas","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2008\/09\/22\/matlab-pragmas\/","title":{"rendered":"MATLAB pragmas"},"content":{"rendered":"<p>In a <a href=\"https:\/\/blogs.mathworks.com\/community\/2008\/04\/28\/code-folding-update-in-r2008a\/#comment-5671\">recent comment<\/a>, Han Geerligs suggested we introduce #pragma-type directives to introduce arbitrary code folding. Well, we do have that, it&#8217;s called cells. You can introduce a cell by placing a <tt><span style=\"color: green;\"><strong>%%<\/strong><\/span><\/tt> at the beginning of a line. You may also need to turn code folding on for cells in order for this to work (see this <a href=\"https:\/\/blogs.mathworks.com\/community\/2008\/04\/28\/code-folding-update-in-r2008a\/\">blog entry<\/a> for instructions). It&#8217;s not exactly the same as a <tt>#region<\/tt>, but it has some nice MATLAB-y features, such as evaluation and shading in the editor (see this <a href=\"https:\/\/blogs.mathworks.com\/community\/2008\/01\/07\/ive-got-something-to-cell-you\/\">blog entry<\/a> for more info).<\/p>\n<p>Other directives like the &#8220;#&#8221; compiler directive in MATLAB are indicated with the <tt><span style=\"color: green;\"><strong>%#<\/strong><\/span><\/tt> token. In R2008a, the MATLAB language supports the following directives:<\/p>\n<ol>\n<li><tt>%#ok<\/tt> &#8211; suppress M-Lint messages<\/li>\n<li><tt>%#eml<\/tt> &#8211; puts a M-file in to Embedded MATLAB mode<\/li>\n<li><tt>%#function<\/tt> and <tt>%#external<\/tt> for the MATLAB compiler<\/li>\n<\/ol>\n<p>Since these directives are also MATLAB comments, you can easily put additional comments on the same line explaining what the token is doing there.<\/p>\n<p>Please don&#8217;t abuse cells for the sake of folding. If your code is too big, for your eyes&#8217; sake, break up the file into separate functions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a recent comment, Han Geerligs suggested we introduce #pragma-type directives to introduce arbitrary code folding. Well, we do have that, it&#8217;s called cells. You can introduce a cell by&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2008\/09\/22\/matlab-pragmas\/\">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],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/261"}],"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=261"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":3466,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/261\/revisions\/3466"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}