{"id":115,"date":"2007-11-14T13:35:38","date_gmt":"2007-11-14T18:35:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2007\/11\/14\/what-version-is-being-used\/"},"modified":"2021-11-21T12:55:33","modified_gmt":"2021-11-21T17:55:33","slug":"what-version-is-being-used","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2007\/11\/14\/what-version-is-being-used\/","title":{"rendered":"What Version is Being Used?"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>Sometimes it's important to have code work in multiple releases of MATLAB, while still taking advantage of new features when\r\n         they exist. In recent articles, I've talked about the <tt>MException<\/tt> class and using <tt>try\/catch<\/tt>.  Here's another tool to add to your collection: <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/verlessthan.html\"><tt>verLessThan<\/tt><\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">ver and version<\/a><\/li>\r\n         <li><a href=\"#6\">References<\/a><\/li>\r\n         <li><a href=\"#7\">Other Compatibility Tools<\/a><\/li>\r\n         <li><a href=\"#8\">Thoughts?<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>ver and version<a name=\"1\"><\/a><\/h3>\r\n   <p>The functions <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/version.html\"><tt>version<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/ver.html\"><tt>ver<\/tt><\/a> allow you to query for the MATLAB version and versions of additional products, as well as extra environmental information.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">v = version<\/pre><pre style=\"font-style:oblique\">v =\r\n7.5.0.342 (R2007b)\r\n<\/pre><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">vmat = ver(<span style=\"color: #A020F0\">'matlab'<\/span>)<\/pre><pre style=\"font-style:oblique\">vmat = \r\n       Name: 'MATLAB'\r\n    Version: '7.5'\r\n    Release: '(R2007b)'\r\n       Date: '02-Aug-2007'\r\n<\/pre><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">vsim = ver(<span style=\"color: #A020F0\">'simulink'<\/span>)<\/pre><pre style=\"font-style:oblique\">vsim = \r\n       Name: 'Simulink'\r\n    Version: '7.0'\r\n    Release: '(R2007b)'\r\n       Date: '02-Aug-2007'\r\n<\/pre><p>There is additional information supplied when I ask for the information to be displayed instead of assigning it to a variable.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">ver <span style=\"color: #A020F0\">simulink<\/span><\/pre><pre style=\"font-style:oblique\">-----------------------------------------------------------------------------\r\nMATLAB Version 7.5.0.342 (R2007b)\r\nMATLAB License Number: DEMO\r\nOperating System: Microsoft Windows XP Version 5.1 (Build 2600: Service Pack 2)\r\nJava VM Version: Java 1.6.0 with Sun Microsystems Inc.\r\n       Java HotSpot(TM) Client VM mixed mode\r\n-----------------------------------------------------------------------------\r\nSimulink                                           Version 7.0        (R2007b)\r\n\r\nTrademarks\r\n------------------\r\nMATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, and xPC\r\nTargetBox are registered trademarks and SimBiology, SimEvents, and\r\nSimHydraulics are trademarks of The MathWorks, Inc. Other product or\r\nbrand names are trademarks or registered trademarks of their respective\r\nholders. \r\n<\/pre>\r\n   <h3>References<a name=\"6\"><\/a><\/h3>\r\n   <p>Here are the references to the blog articles I mentioned earlier.<\/p>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/11\/02\/how-to-safely-try-unknown-code\/\">How to Safely Try Unknown Code<\/a><\/li>\r\n         <li><a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/10\/26\/exceptional-behavior\/\">Exceptional Behavior<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Other Compatibility Tools<a name=\"7\"><\/a><\/h3>\r\n   <p>I know there are other compatibility tools on <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/\">MATLAB Central<\/a> as well, such as <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=17285&amp;objectType=file (now gone)\">this one<\/a> from Tim Davis.\r\n   <\/p>\r\n   <h3>Thoughts?<a name=\"8\"><\/a><\/h3>\r\n   <p>We make a concerted effort to not introduce incompatibilities without good reason.  We also try to supply tools to help you\r\n      manage and use the new tools alongside older ones.  If you have any thoughts or suggestions on the topic of managing compatibility,\r\n      please share them <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=115#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_8938699d3c0343d59aedfff2dddd3661() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='8938699d3c0343d59aedfff2dddd3661 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 8938699d3c0343d59aedfff2dddd3661';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Loren Shure';\r\n        copyright = 'Copyright 2007 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_8938699d3c0343d59aedfff2dddd3661()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.5<br><\/p>\r\n<\/div>\r\n<!--\r\n8938699d3c0343d59aedfff2dddd3661 ##### SOURCE BEGIN #####\r\n%% What Version is Being Used?\r\n% Sometimes it's important to have code work in multiple releases of\r\n% MATLAB, while still taking advantage of new features when they exist.\r\n% In recent articles, I've talked about the |MException| class and using\r\n% |try\/catch|.  Here's another tool to add to your collection:\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/verlessthan.html |verLessThan|>.\r\n%\r\n%% ver and version\r\n% The functions <https:\/\/www.mathworks.com\/help\/matlab\/ref\/version.html |version|>\r\n% and <https:\/\/www.mathworks.com\/help\/matlab\/ref\/ver.html |ver|>\r\n% allow you to query for the MATLAB version and versions of additional\r\n% products, as well as extra environmental information.\r\nv = version\r\n%%\r\n%\r\nvmat = ver('matlab')\r\n%% \r\n%\r\nvsim = ver('simulink')\r\n%%\r\n% There is additional information supplied when I ask for the information\r\n% to be displayed instead of assigning it to a variable.\r\nver simulink\r\n%% verLessThan for MATLAB versions 6.0-7.3\r\n% |varLessThan| started shipping with the MATLAB R2007a release.  To bridge\r\n% the gap back to the year 2000 and MATLAB version 6.0, look at \r\n% <https:\/\/www.mathworks.com\/support\/solutions\/data\/1-38LI61.html?solution=1-38LI61 this solution>\r\n% from the tech support web site.  There's a link near bottom to get \r\n% access to |verLessThan| M-file backward compatible to MATLAB 6.\r\n%% References\r\n% Here are the references to the blog articles I mentioned earlier.\r\n%\r\n% * <https:\/\/blogs.mathworks.com\/loren\/2007\/11\/02\/how-to-safely-try-unknown-code\/ How to Safely Try Unknown Code>\r\n% * <https:\/\/blogs.mathworks.com\/loren\/2007\/10\/26\/exceptional-behavior\/ Exceptional Behavior>\r\n%% Other Compatibility Tools\r\n% I know there are other compatibility tools on \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/ MATLAB Central>\r\n% as well, such as\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=17285&objectType=file this one>\r\n% from Tim Davis.\r\n%% Thoughts?\r\n% We make a concerted effort to not introduce incompatibilities without\r\n% good reason.  We also try to supply tools to help you manage and use the\r\n% new tools alongside older ones.  If you have any thoughts or suggestions\r\n% on the topic of managing compatibility, please share them\r\n% <https:\/\/blogs.mathworks.com\/loren\/?p=115#respond here>.\r\n##### SOURCE END ##### 8938699d3c0343d59aedfff2dddd3661\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Sometimes it's important to have code work in multiple releases of MATLAB, while still taking advantage of new features when\r\n         they exist. In recent articles, I've talked about... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/11\/14\/what-version-is-being-used\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,11],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/115"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":4941,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/115\/revisions\/4941"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}