top of page

# MATLAB BASICS

When you get started with programming, for example, with Matlab software, watch tutorials and read books. Treat learning to program as learning any other language such as Spanish or learning to play the guitar. I list here the fundamentals that you need to know and want to learn early on to program in Matlab. Many beginners struggle with variable types and classes and how to manipulate them. Tackle the challenge head on! Check out MATLAB challenges for beginners after you familiarized yourself with the MATLAB basics.

###### 1. VARIABLE TYPES & CLASSES & OTHER BASICS

You need to know the different variable types and classes. What is and how to handle a ...

• String, Char

• Integer, double, single

• Logical

• Boolean

• Matrix

• Vector, array

• Cell

• Struct

• Function

• if/else/elseif statements

• for/while loops

Fundamental Matlab classes are described here and here.

###### 2. HOW TO MANIPULATE TYPES & CLASSES

You will also need to know to manipulate the variables and data types. How to access elements of a matrix/vector/cell/struct/string? How to concatenate, add, replace, append, reshape data? For this you need to about how to use the different brackets/parentheses types in different contexts: (), [], {}

This seems to be a good starting point. A good book to learn is Matlab for Behavioral Scientists.

###### 3. Logical indexing

Logical indexing is a very powerful way to manipulate data in Matlab. This is one of the things you would want to learn early. It is closely related to point #2. Matlab provides a good tutorial on logical indexing. Read more about it.

###### 4. PLOT DATA, PLOT DATA, PLOT DATA

Learn early on to plot data (i.e., use the "plot" function). This will help you to quickly identify errors in your analysis pipeline and will help you to understand your data. Good Matlab programmers always plot data to get a sense and confirmation of their data analysis.

###### 5. HELP & GOOGLE

Programming is, probably up to about 70%, knowing what exists. Matlab has an in-build function to calculate the mean of the numbers in a vector (called "mean"). Matlab also has an in-built function that provides you with the size of a matrix (called "size").  There are thousands of such functions, and it would be crazy for you to program them again. Use what exists. Google to find what exists. Use the help function in Matlab to figure out how to use a specific function (e.g., the mean or size functions). Programming is problem-solving. Use all the resources available.

bottom of page