Module 1 of 8

MATLAB Fundamentals

3 lessons  ·  UI overview, variables, scripts & formatting

1

First look at MATLAB

Topics covered

  • Overview of the UI
  • Entering inputs into the command line/window using simple arithmetic as an example
  • Mention BODMAS and imaginary numbers
  • Creating variables and assignment (naming rules and procedure)
  • Must start with a letter, may contain numbers, cannot contain symbols except for underscore (spaces are not allowed)
  • Give invalid examples (1var, hello 4, te$t)
  • Any errors and warnings will be displayed in the command window
  • Give valid examples (a2, number_of_pets, really_long_variable_name_which_you_should_avoid_using)
  • Maximum identifier length of 63 characters
  • Brief introduction to arrays/matrices and MATLAB functions via plotting
  • Clearing the command window, workspace and command history
2

Creating a MATLAB script

Topics covered

  • Purpose and procedure of creating a MATLAB script
  • Naming rules of a MATLAB script
  • MATLAB files have the .m extension
  • Explain the current folder UI element and its relationship to the newly created script
  • Show the prompt relating to mismatch between script directory and Current Folder directory
  • Click Change Folder to automatically change Current Folder
  • Add to Path if you do not want to change current folder
3

Script formatting

Topics covered

  • Comments — purpose, positions (before or after lines and identification blocks)
  • White spacing between unrelated code
  • Wrap text or use of ellipses
  • Clicking on a variable name to see all instances of its use
  • Use of Shift+Enter to change all instances of a variable name
  • Sections — purpose and use of Run Section
  • The space is only necessary when creating a section heading
  • Indentation/tabbing