Working With Variables


  • MATLAB stores data in arrays.
  • Use readmatrix to read tabular CSV data into a program.

Arrays


  • M(row, column) indices are used to select data points
  • : is used to take slices of data

Plotting data


  • Use plot to visualize data.

Writing MATLAB Scripts


  • Save MATLAB code in files with a .m suffix.

Repeating With Loops


  • Use for to create a loop that repeats one or more operations.

Making Choices


  • Use if and else to make choices based on values in your program.

Creating Functions


  • Break programs up into short, single-purpose functions with meaningful names.
  • Define functions using the function keyword.

Defensive Programming


  • Use assertions to catch errors, and to document what behavior is expected.
  • Write tests before code.