{"id":133,"date":"2008-04-01T11:03:35","date_gmt":"2008-04-01T16:03:35","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2008\/04\/01\/matlab-language-translator\/"},"modified":"2016-08-07T13:56:07","modified_gmt":"2016-08-07T18:56:07","slug":"matlab-language-translator","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2008\/04\/01\/matlab-language-translator\/","title":{"rendered":"MATLAB Language Translator"},"content":{"rendered":"<div class=\"content\">\n<p>Google recently made a splash about its e-api-tools-for.html latest language tools. Translating one computer language to another is useful but pass\u00e9. But suppose you could translate a computer language to<br \/>\na human language: MATLAB -&gt; English and English -&gt; MATLAB. Type in your word problem and get the code instantly. It could<br \/>\nhelp you with your MATLAB accent, or, if English is not your first natural language, you might learn some vernacular from<br \/>\nMATLAB's interpretation.<\/p>\n<p>&nbsp;<\/p>\n<h3>Contents<\/h3>\n<div>\n<ul>\n<li><a href=\"#1\">Some Translations<\/a><\/li>\n<li><a href=\"#2\">Command Duality<\/a><\/li>\n<li><a href=\"#5\">What Are Your Translation Needs?<\/a><\/li>\n<\/ul>\n<\/div>\n<h3>Some Translations<a name=\"1\"><\/a><\/h3>\n<p>In particular, such a translator might be good at recognizing and translating common phrases. Here are but a few of the phrases<br \/>\nthe translator (under development) gets right.<\/p>\n<div>\n<ul>\n<li><tt>eye(newt)<\/tt>, from Shakespeare's hags<\/li>\n<li><tt>ceil(approval)<\/tt>, from Good Housekeeping<\/li>\n<li><tt>wait(theWorld)<\/tt><\/li>\n<li><tt>angle(repose)<\/tt>, an excellent book by Wallace Stegner<\/li>\n<li><tt>balance(power)<\/tt>, <tt>axis(power)<\/tt>, etc., assuming you've pre-empted the function with your own variable or function, of course<\/li>\n<li><tt>gallery(art)<\/tt><\/li>\n<li><tt>length(day)<\/tt> (<tt>day<\/tt> has the same caveat as <tt>power<\/tt> above)<\/li>\n<li><tt>residue(ashes)<\/tt><\/li>\n<li><tt>sign(theTimes)<\/tt><\/li>\n<li><tt>sound(music)<\/tt>, thanks to Julie Andrews, among others<\/li>\n<li><tt>theTotal = sum(theParts)<\/tt><\/li>\n<\/ul>\n<\/div>\n<p>Notice how the parentheses are pronounced in English : \"of\".<\/p>\n<h3>Command Duality<a name=\"2\"><\/a><\/h3>\n<p>The MATLAB translator understands command-function duality and the nuances of English. It would not do to write the last example as<\/p>\n<div>\n<ul>\n<li><tt>wait theWorld<\/tt><\/li>\n<\/ul>\n<\/div>\n<p>Nor would<\/p>\n<div>\n<ul>\n<li><tt>polar bear<\/tt><\/li>\n<\/ul>\n<\/div>\n<p>be okay because <tt>polar<\/tt> doesn't take a character array for its first argument.<\/p>\n<p>However, it would be okay to say<\/p>\n<div>\n<ul>\n<li><tt>global warming<\/tt><\/li>\n<li><tt>median strip<\/tt><\/li>\n<\/ul>\n<\/div>\n<h3>What Are Your Translation Needs?<a name=\"5\"><\/a><\/h3>\n<p>Sure, we will translate between MATLAB and other languages once we have the English version ready to go. And, I should warn<br \/>\nyou that Steve Eddins from the <a href=\"https:\/\/blogs.mathworks.com\/steve\/\">Steve on Image Processing<\/a> blog has been working for years on <tt>mindread.m<\/tt> as well. Beyond these two obvious needs, what other translation needs do you have? Or other thoughts on this post? What<br \/>\nabout MATLAB poetry (Tim?)? Let me know <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=133#respond\">here<\/a>.<\/p>\n<p><script>\/\/ <![CDATA[\nfunction grabCode_44d4c8e864a14d4aab3e4c0bc735cc26() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='44d4c8e864a14d4aab3e4c0bc735cc26 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 44d4c8e864a14d4aab3e4c0bc735cc26';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Loren Shure';\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n\n\n\n\n<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\n\n\n\n\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }\n\/\/ ]]><\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\"><a><span style=\"font-size: x-small; font-style: italic;\">Get<br \/>\nthe MATLAB code<br \/>\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>Published with MATLAB\u00ae 7.6<\/p>\n<\/div>\n<p><!--\n44d4c8e864a14d4aab3e4c0bc735cc26 ##### SOURCE BEGIN #####\n%% MATLAB Language Translator\n% Google recently made a splash about its\n% <http:\/\/googleajaxsearchapi.blogspot.com\/2008\/03\/introducing-ajax-languag % e-api-tools-for.html latest language tools>. Translating one computer\n% language to another is useful but pass\u00c3\u00a9. But suppose\n% you could translate a computer language to a human language: MATLAB ->\n% English and English -> MATLAB. Type in your word problem and get the code\n% instantly. It could help you with your MATLAB accent, or, if English is\n% not your first natural language, you might learn some vernacular from\n% MATLAB's interpretation.\n%% Some Translations\n% In particular, such a translator might be good at recognizing and\n% translating common phrases.  Here are but a few of the phrases the\n% translator (under development) gets right.\n%\n% * |eye(newt)|, from Shakespeare's hags\n% * |ceil(approval)|, from Good Housekeeping\n% * |wait(theWorld)|\n% * |angle(repose)|, an excellent book by Wallace Stegner\n% * |balance(power)|, |axis(power)|, etc., assuming you've pre-empted the function with your own\n% variable or function, of course\n% * |gallery(art)|\n% * |length(day)| (|day| has the same caveat as |power| above)\n% * |residue(ashes)|\n% * |sign(theTimes)|\n% * |sound(music)|, thanks to Julie Andrews, among others\n% * |theTotal = sum(theParts)|\n%\n% Notice how the parentheses are pronounced in English : \"of\".\n%% Command Duality\n% The MATLAB translator understands <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/matlab_prog\/f7-58170.html#f7-58289 command-function duality> and the\n% nuances of English.  It would not do to write the last example as\n%\n% * |wait theWorld|\n%%\n% Nor would\n%\n% * |polar bear|\n%\n% be okay because |polar| doesn't take a character array for its first\n% argument.\n%%\n% However, it would be okay to say\n%\n% * |global warming|\n% * |median strip|\n%% What Are Your Translation Needs?\n% Sure, we will translate between MATLAB and other languages once we have\n% the English version ready to go.  And, I should warn you that Steve\n% Eddins from the <https:\/\/blogs.mathworks.com\/steve\/ Steve on Image Processing> blog\n% has been working for years on |mindread.m| as well.  Beyond these two\n% obvious needs, what other translation needs do you have?  Or other\n% thoughts on this post?  What about MATLAB poetry (Tim?)?  Let me know\n% <https:\/\/blogs.mathworks.com\/loren\/?p=133#respond here>.\n\n##### SOURCE END ##### 44d4c8e864a14d4aab3e4c0bc735cc26\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\nGoogle recently made a splash about its e-api-tools-for.html latest language tools. Translating one computer language to another is useful but pass\u00e9. But suppose you could translate a computer... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/04\/01\/matlab-language-translator\/\">read more >><\/a><\/p>\n","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/133"}],"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=133"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":1989,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/133\/revisions\/1989"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}