{"id":655,"date":"2013-04-01T08:14:09","date_gmt":"2013-04-01T13:14:09","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/?p=655"},"modified":"2013-03-27T14:16:06","modified_gmt":"2013-03-27T19:16:06","slug":"new-datatype-under-development-for-possible-matlab-release","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2013\/04\/01\/new-datatype-under-development-for-possible-matlab-release\/","title":{"rendered":"New Datatype under Development for Possible MATLAB Release"},"content":{"rendered":"\r\n<div class=\"content\"><!--introduction--><p>There is a new datatype we are playing around with that we hope to make available in an upcoming release and we would like your input beforehand.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#0db87324-2965-4901-8815-a6971dc0e459\">New Datatype in Action<\/a><\/li><li><a href=\"#b3bda645-6f1d-4c77-9b0f-97bded4ae828\">Let's Examine the Output<\/a><\/li><li><a href=\"#d2c273a6-73dd-4ef1-875b-086b90250ba3\">Should We Invest More Resources?<\/a><\/li><\/ul><\/div><h4>New Datatype in Action<a name=\"0db87324-2965-4901-8815-a6971dc0e459\"><\/a><\/h4><p>Let me show you the new datatype in action so you can first get a feel for it.<\/p><pre class=\"codeinput\">inputData = magic(3)\r\n<\/pre><pre class=\"codeoutput\">inputData =\r\n     8     1     6\r\n     3     5     7\r\n     4     9     2\r\n<\/pre><pre class=\"codeinput\">outputValues = dis(inputData);\r\n<\/pre><h4>Let's Examine the Output<a name=\"b3bda645-6f1d-4c77-9b0f-97bded4ae828\"><\/a><\/h4><pre class=\"codeinput\">outputValues\r\n<\/pre><pre class=\"codeoutput\">Why are you asking?\r\n     4     2     3\r\n     1     9     6\r\n     8     7     5\r\n<\/pre><p>Well, that's a bit strange, isn't it?  I wonder what the relationship between <tt>inputData<\/tt> and <tt>outputValues<\/tt> is.  What can we learn about <tt>outputValues<\/tt>?<\/p><pre class=\"codeinput\">whos <span class=\"string\">outputValues<\/span>\r\n<\/pre><pre class=\"codeoutput\">  Name              Size            Bytes  Class    Attributes\r\n\r\n  outputValues      1x1               248  dis                \r\n\r\n<\/pre><p>Well, it's a <tt>dis<\/tt> array.  Let's look at it again.<\/p><pre class=\"codeinput\">outputValues\r\n<\/pre><pre class=\"codeoutput\">What's it matter to you?\r\n     5     6     9\r\n     4     3     2\r\n     7     8     1\r\n<\/pre><p>Say what?  Let's check it a few more times.<\/p><pre class=\"codeinput\">outputValues\r\noutputValues\r\noutputValues\r\n<\/pre><pre class=\"codeoutput\">Who wants to know?\r\n     6     3     9\r\n     5     8     7\r\n     4     2     1\r\nWho wants to know?\r\n     5     2     9\r\n     1     4     8\r\n     7     6     3\r\nWho are you to ask me that?\r\n     5     3     7\r\n     9     8     2\r\n     1     4     6\r\n<\/pre><p>Hoping you get the double meaning here - the <tt>dis<\/tt> array not only mixes up the values of the input for display purposes, but also tries to gently *dis*respect you along the way.<\/p><p>Even though this is a silly class, I'll show you the code so you can see how simple it is to make such a class.<\/p><pre class=\"codeinput\">type <span class=\"string\">dis<\/span>\r\n<\/pre><pre class=\"codeoutput\">\r\nclassdef dis\r\n    %dis dis is a class.\r\n    %   In fact, it's a declasse class.\r\n    \r\n    properties\r\n        Data\r\n    end\r\n    properties (Access=protected)\r\n        Original\r\n    end\r\n    \r\n    properties (Constant)\r\n        Answers = {'Why are you asking?' ,...\r\n            'What''s it matter to you?',...\r\n            'Who are you to ask me that?',...\r\n            'Who wants to know?',...\r\n            'What''s the big deal?'}\r\n    end\r\n    \r\n    methods\r\n        function display(obj)\r\n            disp(dis.Answers{randi(length(dis.Answers),1)})\r\n            obj.Data(:) = obj.Data(randperm(numel(obj.Data)));\r\n            disp(obj.Data)\r\n        end\r\n        function obj = dis(in)\r\n            obj.Original = in;\r\n            obj.Data = reshape(in(randperm(numel(in))),size(in));\r\n        end\r\n    end\r\n    \r\nend\r\n\r\n\r\n<\/pre><h4>Should We Invest More Resources?<a name=\"d2c273a6-73dd-4ef1-875b-086b90250ba3\"><\/a><\/h4><p>Of course, I could also add some numeric functions like <tt>plus<\/tt> to <tt>dis<\/tt>, but I didn't take the time, in case you didn't find this possible new MATLAB addition useful. So please share your thoughts with us <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=655#respond\">here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_a181c2e627784116bd2a8279503e14c9() {\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='a181c2e627784116bd2a8279503e14c9 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a181c2e627784116bd2a8279503e14c9';\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        copyright = 'Copyright 2013 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 copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\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     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_a181c2e627784116bd2a8279503e14c9()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2013a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2013a<br><\/p><\/div><!--\r\na181c2e627784116bd2a8279503e14c9 ##### SOURCE BEGIN #####\r\n%% New Datatype under Development for Possible MATLAB Release\r\n% There is a new datatype we are playing around with that we hope to make\r\n% available in an upcoming release and we would like your input beforehand.\r\n%% New Datatype in Action\r\n% Let me show you the new datatype in action so you can first get a feel\r\n% for it.\r\ninputData = magic(3)\r\n%%\r\noutputValues = dis(inputData);\r\n%% Let's Examine the Output\r\noutputValues\r\n%%\r\n% Well, that's a bit strange, isn't it?  I wonder what the relationship\r\n% between |inputData| and |outputValues| is.  What can we learn about\r\n% |outputValues|?\r\nwhos outputValues\r\n%%\r\n% Well, it's a |dis| array.  Let's look at it again.\r\noutputValues\r\n%% \r\n% Say what?  Let's check it a few more times.\r\noutputValues\r\noutputValues\r\noutputValues\r\n%% \r\n% Hoping you get the double meaning here - the |dis| array not only mixes\r\n% up the values of the input for display purposes, but also tries to gently\r\n% *dis*respect you along the way.  \r\n%%\r\n% Even though this is a silly class, I'll show you the code so you can see\r\n% how simple it is to make such a class.\r\ntype dis\r\n%% Should We Invest More Resources?\r\n% Of course, I could also add some numeric functions like |plus| to |dis|,\r\n% but I didn't take the time, in case you didn't find this possible new\r\n% MATLAB addition useful. So please share your thoughts with us\r\n% <https:\/\/blogs.mathworks.com\/loren\/?p=655#respond here>.\r\n##### SOURCE END ##### a181c2e627784116bd2a8279503e14c9\r\n-->","protected":false},"excerpt":{"rendered":"<!--introduction--><p>There is a new datatype we are playing around with that we hope to make available in an upcoming release and we would like your input beforehand.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2013\/04\/01\/new-datatype-under-development-for-possible-matlab-release\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[33],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/655"}],"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=655"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/655\/revisions"}],"predecessor-version":[{"id":663,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/655\/revisions\/663"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}