{"id":4912,"date":"2013-11-15T09:00:55","date_gmt":"2013-11-15T14:00:55","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=4912"},"modified":"2018-01-08T15:06:09","modified_gmt":"2018-01-08T20:06:09","slug":"whats-in-that-mat-file","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2013\/11\/15\/whats-in-that-mat-file\/","title":{"rendered":"What&#8217;s in that MAT File?"},"content":{"rendered":"<div class=\"content\"><!--introduction--><!--\/introduction--><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911\">Brett<\/a>'s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42159-matwho\">\"matwho\"<\/a>, by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/74912\">Benjamin Kraus<\/a>.<\/p><p>Want to know what's in a MAT file without loading it? <tt>matwho<\/tt> is for you. Simple, effective, well-implemented, and useful. And fast!<\/p><p>Benjamin's file, which sprang from an <a >interesting discussion on CSSM<\/a>, provides an easy-to-use wrapper around MATLAB's MatGetDir MEX function. His function is often faster than querying the file with <tt>who<\/tt>, but quite honestly, the value of <tt>matwho<\/tt> arises from the relative ease of the calling syntax: I have an easier time remembering 'matwho('test.mat')' instead of 'whos('-file','test.mat').<\/p><p>Calling <tt>who<\/tt> is pretty darned fast, too...I don't think I would have gone to the trouble that Benjamin did. But I'm glad he did. ;)<\/p><p>Not earth-shattering, but useful nonetheless. And I enjoyed reading through some of the discussion in CSSM on the topic.<\/p><p>As always, I welcome your <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=4912#respond\">thoughts and comments<\/a>. Or leave feedback for Benjamin <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42159-matwho#comments\">here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_10b2f5ddea974271af7abcfbc0138d7a() {\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='10b2f5ddea974271af7abcfbc0138d7a ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 10b2f5ddea974271af7abcfbc0138d7a';\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_10b2f5ddea974271af7abcfbc0138d7a()\"><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; R2013b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2013b<br><\/p><\/div><!--\r\n10b2f5ddea974271af7abcfbc0138d7a ##### SOURCE BEGIN #####\r\n%% What's in that MAT File?\r\n%% \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911 Brett>'s Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42159-matwho \"matwho\">, by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/74912 Benjamin Kraus>.\r\n\r\n%% \r\n% Want to know what's in a MAT file without loading it? |matwho| is for\r\n% you. Simple, effective, well-implemented, and useful. And fast!\r\n\r\n%%\r\n% Benjamin's file, which sprang from an <http:\/\/view_thread\/316593 interesting discussion on CSSM>,\r\n% provides an easy-to-use wrapper around MATLAB's MatGetDir MEX function.\r\n% His function is often faster than querying the file with |who|, but\r\n% quite honestly, the value of |matwho| arises from the relative ease of\r\n% the calling syntax: I have an easier time remembering 'matwho('test.mat')' instead of\r\n% 'whos('-file','test.mat'). \r\n\r\n%%\r\n% Calling |who| is pretty darned fast, too...I\r\n% don't think I would have gone to the trouble that Benjamin did. But I'm\r\n% glad he did. ;)\r\n\r\n%%\r\n% Not earth-shattering, but useful nonetheless. And I enjoyed reading\r\n% through some of the discussion in CSSM on the topic.\r\n\r\n%%\r\n% As always, I welcome your\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=4912#respond thoughts and comments>.\r\n% Or leave feedback for Benjamin\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42159-matwho#comments here>.\r\n##### SOURCE END ##### 10b2f5ddea974271af7abcfbc0138d7a\r\n-->","protected":false},"excerpt":{"rendered":"<p>Brett's Pick this week is \"matwho\", by Benjamin Kraus.Want to know what's in a MAT file without loading it? matwho is for you. Simple, effective, well-implemented, and useful. And fast!Benjamin's... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2013\/11\/15\/whats-in-that-mat-file\/\">read more >><\/a><\/p>","protected":false},"author":34,"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\/4912"}],"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\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=4912"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4912\/revisions"}],"predecessor-version":[{"id":9300,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4912\/revisions\/9300"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=4912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=4912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=4912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}