MatLab Basics Flashcards
what are the Two Main Windows in Matlab?
- Command Window
- Editor Window
Uses of Command Window in MatLab
Useful for testing, immediate output
Uses of Editor Window in Matlab
-Word Processing environment
-Multiple lines of code
-Can be saved and exectued
what are M files, what do they contain?
Matlab Script File
-series of commands
-can be main program or function
-.m file extension
Function
Executable process
-Can’t be executed independently
-must be called by a statement
-data is passed to a function
-output is passed back to calling program
Program
Executes a series of commands or functions
-all variables created in a program are considered global variables
-can be executed independantly
-can be executed in another program
Green Text
Comments
-preceded by a %
-not included in operation
Hierarchy of functions
Main Program -> function -> (sub) function
Variable Naming Protocol
Rule 1: Must consist of only letters a-z, digits 0-9 and underscore
Rule 2: Must start with a letter
Notes:
-up to 31 characters
-case sensitive
Numeric Variable
contains only numbers
String Variable
contains numbers and letters
Basic Arithmetic Functions in MatLab
Addition +
Minus -
Multiply element by element .*
Divide element by element ./
Matrix Multiply *
Matrix Right Divide /
Element by element math
-Most functions will not use matrix math
-item to item comparison
-Arrays must be of equal dimensions
Where are Relational Operators used?
Used in loops and if statements
Comparative Relational Operators
equal
not equal
less than
greater than
less than or equal
greater than or equal