What is MATLAB?


  • MATLAB is used in many fields and can be used to analysis, process, model and much more
  • MATLAB is proprietary which has its own benefits and costs

Matlab Layout


  • The MATLAB interface is very customisable, adjust it to suit you
  • Use the command window for quick tasks like exploring data, testing, etc.
  • Use the editor for developing code you want to persist between sessions

Creating Variables


  • Variables are the main way we access and use data in MATLAB
  • Variables can store many types of data including multidimensional data
  • Creating multidimensional arrays is done with square brackets

Working with Variables


  • Use functions to create, edit and operate on variables
  • Operations are used to perform simple mathematical functions
  • help and docs are valuable tools for understanding functions

Plotting


  • Figures in MATLAB are by default interactive
  • Hold on is needed to place multiple plots on the same figure
  • Label and title your plots for extra clarity

Logic


  • The result of a relational operator is a logical array
  • if, elseif and else can be used to create powerful conditions
  • Logical arrays can be used to index variables

Control


  • Use for loops for when you know how many iterations to loop, while loops when you don’t
  • Break and continue allow you to exit or skip loops
  • Use indents to keep looped code clear