{"id":28,"date":"2016-07-23T12:42:59","date_gmt":"2016-07-23T20:42:59","guid":{"rendered":"http:\/\/wonghoi.humgar.com\/blog\/?p=28"},"modified":"2018-09-01T12:20:14","modified_gmt":"2018-09-01T20:20:14","slug":"how-i-learned-matlab-inside-out","status":"publish","type":"post","link":"https:\/\/wonghoi.humgar.com\/blog\/2016\/07\/23\/how-i-learned-matlab-inside-out\/","title":{"rendered":"How I learned MATLAB inside out"},"content":{"rendered":"<p>Back when I was a struggling graduate student working 3 university jobs to stay afloat, one of the job was to build a multi-center data collection system that take cares of remote data upload,\u00a0store it in a database and visualize the waveforms and records.<\/p>\n<p>I surveyed\u00a0other platforms and languages for a couple of months and finally settled on MATLAB because at the time MATLAB had the most convenient data types (cells), data loading\/saving (&#8216;.mat&#8217; files so I don&#8217;t have to manage the datatypes\/format), external interfaces, and most importantly MATLAB FileExchange (FEX) pretty much cover every generic idea\u00a0I can think of. With MATLAB, my work is pretty much down to\u00a0coding the high level &#8216;business&#8217; logic.<\/p>\n<p>And no, I wasn&#8217;t biased towards MATLAB at the time because I have a signal processing background. I didn&#8217;t know much about MATLAB&#8217;s programming support back then other than\u00a0number crunching (just like the 90% of the public who misundestood the power of the language), so I wouldn&#8217;t choose it for a software project at that level of complexity without much research.<\/p>\n<p>Learning the\u00a0guts of MATLAB, architecturing and coding\u00a0the entire system took me only 3 months (well, it included a 1 month non-stop 16 hours a day, 7-days a week shut-in programming). Not a shabby platform for a project that is supposed to take 4 years. In fact, the rest of the time was spent<\/p>\n<ol>\n<li>reading\u00a0the last owners *#@&amp;ed up perl code and fighting to get\u00a0the fragile linux setup to work on other machines, then reverse the entire project requirements from the source code because there wasn&#8217;t any documentation and the previous owners graduated.<\/li>\n<li>reconstruct Guidant&#8217;s half-finished (done by a 3rd party then abandoned) binary data reader by finishing\u00a0the hardest part of the incomplete XSLT code.<\/li>\n<\/ol>\n<p>The rest that has to do with MATLAB was relatively easy once I learned the main ideas through their documentation, newsgroups, <a href=\"http:\/\/blogs.mathworks.com\/loren\/\">Loren&#8217;s blog<\/a> and the official support.<\/p>\n<p>To understand and appreciate the beauty of MATLAB and use it effectively, you have to get past the following hurdles:<\/p>\n<ol>\n<li>Basic data structures: cell, struct and language features.<\/li>\n<li>Vectorization: use for-loops only in limited cases<\/li>\n<li>Anonymous function (Lambdas), cellfun(), arrayfun(), bsxfun(), structfun()<\/li>\n<li>Overloading and OOP<\/li>\n<li>Tables (Heterogeneous data structures) and Categorical objects (Nominal, Ordinal)<\/li>\n<\/ol>\n<p>or else you are coding it like a C programmer: a complete waste of\u00a0MATLAB&#8217;s license fees. If you know these 5 aspects of MATLAB well and would say\u00a0there are <span style=\"text-decoration: underline;\">strictly<\/span> superior options out there, please let me know in the comments section and I&#8217;ll look into it.<\/p>\n<p>&nbsp;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_28\" class=\"pvc_stats all  \" data-element-id=\"28\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Back when I was a struggling graduate student working 3 university jobs to stay afloat, one of the job was to build a multi-center data collection system that take cares of remote data upload,\u00a0store it in a database and visualize &hellip; <a href=\"https:\/\/wonghoi.humgar.com\/blog\/2016\/07\/23\/how-i-learned-matlab-inside-out\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_28\" class=\"pvc_stats all  \" data-element-id=\"28\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-matlab"],"_links":{"self":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":3,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":918,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions\/918"}],"wp:attachment":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}