Course notes
Notes from when I took Mike X’s course as a refresher for CSHL Neural Data Science summer school.
Course: Mike X Cohen’s course on Udemy
GUI
- Can set more information for variables. Recommended information to add apart from variable name and value is: size, bytes, type.
Variables
-
Type character array and string are different. Basically best not to use string type. Not sure what it is used for.
-
Reminder: Square (array) allows concatenation. Cell arrays on the other hand will create cells for every value between the curly brackets
-
Multiline comments (to use if needed)
-
Structures
Good use of structures to replace “objects”. The nice part of this is that you can make struct arrays with particular types of elements.
Functions
Mike talks about a nice way of writing functions. Starting with comments to describe the algorithm the filling in the details. This is a nice way of forcing writing down the algorithm before coding (which often is the cause of long/confusing code).
Read and writing
-
Can read ‘clean’ text files using load. Also can use the standard, xlsread (or csvread), or just load for matlab files
-
dlmwrite allows to write data with any defined delimiters
\t for tab or space or comma
. csvwrite is a specific instance of this.
Plotting
- imagesec - good for visualizing matrices
Debugging
- Use 1i instead of i (will get confused with for i iterator)
.*
works as element to element multiplication only if the matrix are of the same sizes (row, col numbers). If the row columns are flipped, matlab will silently do a outer product multiplication.- tic-toc
- can use to measure how long a few lines of code take to run.
- matlab profiler
- a nice way of measuring how much different lines of code take
- seems super useful actually
- not sure why I was not using it 😅
- there seems to be some tmpscript issue - that is code needs to be moved to a file called tmpscript. Not sure if this has to be exactly the specific one or just any script file.
Tips
-
From 2019/2020, there is an addon manager which one can use to install toolboxes you want, so no need for a 30GB all toolbox install anymore! You will have to sign in with your account though, but the storage save is massive.
-
Archlinux + sway
For sway, you need to enable_JAVA_AWT_WM_NONREPARENTING=1
. Although you might have defined it in the environment, for some reason running matlab from commandline does not automatically use the variable. Create a desktop entry, which seems to work well, or use the following line: