{"id":2338,"date":"2008-10-24T07:30:39","date_gmt":"2008-10-24T12:30:39","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2008\/10\/24\/displaying-structures\/"},"modified":"2008-10-24T11:01:32","modified_gmt":"2008-10-24T16:01:32","slug":"displaying-structures","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2008\/10\/24\/displaying-structures\/","title":{"rendered":"Displaying Structures"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/19-delta-sigma-toolbox\">ANY2CSV<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/30533\">Felix Zoergiebel<\/a>.\r\n   <\/p>\r\n   <p>I use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/matlab_prog\/f2-88951.html\">structures<\/a> quite often. It allows me to store heterogeneous information in one variable, and I can have structures within structures\r\n      as well. Sometimes, I go crazy and make many levels of hierarchy to organize my information.\r\n   <\/p>\r\n   <p>Let's take a look at this data.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">load <span style=\"color: #A020F0\">data<\/span>\r\nwhos<\/pre><pre style=\"font-style:oblique\">  Name      Size            Bytes  Class     Attributes\r\n\r\n  a         4x1              2704  struct              \r\n\r\n<\/pre><p>This is a structure that contains information from a series of stress tests. I can dig into the structure to see its contents...<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">a(1)<\/pre><pre style=\"font-style:oblique\">ans = \r\n     TestName: 'Stress Test One'\r\n    Condition: 'fast'\r\n         Test: [2x1 struct]\r\n<\/pre><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">a(1).Test(1)<\/pre><pre style=\"font-style:oblique\">ans = \r\n     Date: 'May 3'\r\n    Score: 89\r\n<\/pre><p>But sometimes, I just want to view everything at once. ANY2CSV allows you to do just that. It flattens the structure and either\r\n      displays it on the screen or saves it as a CSV file.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">any2csv(a, <span style=\"color: #A020F0\">','<\/span>, 0, <span style=\"color: #A020F0\">'a.csv'<\/span>);<\/pre><p>Now, I have a summary of the data stored in the structure.<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/any2csv.png\"> <\/p>\r\n   <p>Very nice! I also want to thank Felix for his quick response to my enhancement request. I asked him whether the fields of\r\n      the structure could be displayed vertically, rather than horizontally, and he updated the submission in a timely manner.\r\n   <\/p>\r\n   <p><b>Comments?<\/b><\/p>\r\n   <p>Data visualizations don't always come in the form of graphs. We'd love to hear about other interesting ways of viewing information.\r\n      Tell us about it <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2338#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_ee61a0c9b04a4cec9b310a9a99797002() {\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='ee61a0c9b04a4cec9b310a9a99797002 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ee61a0c9b04a4cec9b310a9a99797002';\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 = 'Jiro Doke';\r\n        copyright = 'Copyright 2008 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_ee61a0c9b04a4cec9b310a9a99797002()\"><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.7<br><\/p>\r\n<\/div>\r\n<!--\r\nee61a0c9b04a4cec9b310a9a99797002 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/19-delta-sigma-toolbox\r\n% ANY2CSV> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/30533\r\n% Felix Zoergiebel>.\r\n%\r\n% I use <https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/matlab_prog\/f2-88951.html\r\n% structures> quite often. It allows me to store heterogeneous information\r\n% in one variable, and I can have structures within structures as well.\r\n% Sometimes, I go crazy and make many levels of hierarchy to organize my\r\n% information.\r\n%\r\n% Let's take a look at this data.\r\n\r\nload data\r\nwhos\r\n\r\n%%\r\n% This is a structure that contains information from a series of stress\r\n% tests. I can dig into the structure to see its contents...\r\n\r\na(1)\r\n\r\n%%\r\n\r\na(1).Test(1)\r\n\r\n%%\r\n% But sometimes, I just want to view everything at once. ANY2CSV allows you\r\n% to do just that. It flattens the structure and either displays it on the\r\n% screen or saves it as a CSV file.\r\n\r\nany2csv(a, ',', 0, 'a.csv');\r\n\r\n%%\r\n% Now, I have a summary of the data stored in the structure.\r\n%\r\n% <<any2csv.png>>\r\n%\r\n% Very nice! I also want to thank Felix for his quick response to my\r\n% enhancement request. I asked him whether the fields of the structure\r\n% could be displayed vertically, rather than horizontally, and he updated\r\n% the submission in a timely manner.\r\n%\r\n% *Comments?*\r\n%\r\n% Data visualizations don't always come in the form of graphs. We'd love to\r\n% hear about other interesting ways of viewing information. Tell us about\r\n% it <https:\/\/blogs.mathworks.com\/pick\/?p=2338#respond here>.\r\n##### SOURCE END ##### ee61a0c9b04a4cec9b310a9a99797002\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Jiro's pick this week is ANY2CSV by Felix Zoergiebel.\r\n   \r\n   I use structures quite often. It allows me to store heterogeneous information in one variable, and I can have structures within... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/10\/24\/displaying-structures\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2338"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2338"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2338\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}