MATLAB: A Handy Coding Experience

  • Posted by bsimms
  • On August 4, 2016

As my journey into the realm of data science continues I thought I would comment on MATLAB, a proprietary player in data analytics software.  I have been using MATLAB daily for the past few months in order to automate repetitive electrophysiology data analyses. Having limited experience with the program and all of its data structures certainly restricts my ability to criticize it thoroughly.  Nevertheless, I have found three handy little features I truly appreciate.

  1.  Code Readability — specifically loops and functions
  2.  Warnings/errors marked as you type with detailed fixes
  3. Ability to easily change all instances of a variable name

 

Code Readability

MATLAB (formatting enforced)

Ease of reading loops

 

 

 

 

 

 

 

 

 

R (formatting not necessary)

R Loops Not Easy To Read

 

 

 

 

 

 

 

 

Unlike  in R, where “{” and “}” brackets encapsulate the body of loop components (or functions), and do not have to be formatted to work properly (see example above), MATLAB physically draws a line from start to finish of  the parent loop and enforces indentation of nested loops . I find — at least for a novice coder like myself– that this enforced structure dramatically helps code readability and reduces confusion. A critic may suggest that MATLAB  should not have to indent nested loops for the programmer, and that a good R programmer should be doing this anyways. True, but  I still  like that MATLAB enforces code readability because not everyone is prudent in this regard.

 

Warnings/Errors Marked With Detailed Fixes

Warnings Errors Described as you type

Most if not all software comes with “help files”, but MATLAB does a really nice job highlighting potential problems as you type.  In near real-time MATLAB can provide a detailed explanation of what it thinks is wrong with your code and suggestions to fix the problem. Don’t most analytics programs do this? Yes, but not this well.

 

Easily Change All Instances of a Variable Name

Change all instances of variable name with shortcut

Maybe this one can only be appreciated by programmers who enjoy perfecting variable names, but I find it quite handy! Instead of the standard “find/replace” word processor option like what other analytics software run with, MATLAB provides a key shortcut to change all instances of a variable name automatically, after the user edits one instance. Very convenient and a time saver.

Thanks for reading!

 

0 Comments

Leave Reply

Your email address will not be published. Required fields are marked *