MATLAB

Matlab Basics

Matlab Array

Matlab Types

Matlab Function

Matlab Functions List

Matlab Functions List

Rmk

  • ~~Only functions referenced in my notes are listed.~~
  • Functions without a dedicated note are those that
    • have a single syntax with nothing else worth saying,
    • duplicate the usage of another function, or
    • are rarely used
      • For these, only the most basic syntax is kept.
  • Symbols
    • ... denotes variable-length argument omission
    • __ repeats the preceding syntax
    • <> marks an optional argument with a default value
    • <[]> means the brackets [] may be omitted, i.e. the argument may be either a variable-length list or an array

Basics

Mathematics

  • Matlab Random Number Generation
  • round(a): nearest integer to a; break ties by rounding away from zero
  • fix(a): nearest integer to a toward
  • floor(a): nearest integer to a toward
  • ceil(a): nearest integer to a toward
  • real(z): real part of complex number z
  • imag(z): imaginary part of complex number z
  • abs(z): absolute or modulus
  • angle(z): phase angle in radians, in the range
  • conj(z): conjugate of complex number z
  • complex(a,b): complex number with real part a and imaginary part b

Matrix Manipulation

Data Type Construction

Identity Test

  • Any function that starts with is returns a logical value indicating whether the tested variable satisfies a certain condition
  • Without special comment, the syntax is iscond(a), which returns 1 if the condition cond is satisfied by variable a, and 0 otherwise
  • isa(var,type) tests if var is of type type
  • isnumeric
  • isfloat
  • isstruct
  • islogical
  • ischar
  • iscell
  • iscellstr tests if input is a cell array of strings
  • isnan
  • isinf
  • isfinite
  • isinteger
  • isreal
  • isscalar
  • isvector
  • issparse
  • isspace
  • isempty
  • isdir
  • iskeyword
  • isvarname tests if the input is a valid variable name
  • isglobal
  • ismember(var,set) tests if var is a member of set
  • isequal(a,b,...) tests if all inputs are equal
  • isequalwithequalnans(a,b,...) tests if all inputs are equal, treating NaN values as equal
  • issorted
  • isfield(struct,field) tests if struct has a field named field
Link to original

Matlab Operations

Matlab Operator

Operator

Matlab Arithmetic Operations

SymbolRole
+Addition; Unary plus
-Subtraction; Unary minus
.*Element-wise multiplication
*Matrix multiplication
./Element-wise right division
/Matrix right division
.\Element-wise left division
\Matrix left division (also known as backslash)
.^Element-wise power
^Matrix power
.'Transpose
'Complex conjugate transpose

Matlab Relational Operations

SymbolRole
==Equal to
~=Not equal to
>Greater than
>=Greater than or equal to
<Less than
<=Less than or equal to

Matlab Logical Operations

SymbolRole
&Find logical AND
&&Find logical AND (with short-circuiting)
~Find logical NOT

String and Character Formatting

SymbolEffect on Text
''Single quotation mark
Cell delimiter
%{ %}Block comments that extend beyond one line
!Operating system command
?Metaclass for MATLAB class
~Argument placeholder to suppress specific input or output arguments
< &Specify superclasses
.?Specify fields of name-value structure when using function argument validation

Operator Precedence

  1. ()
  2. ~, sign +, -
  3. ^, .^, transpose ', .'
  4. .*, *, ./, /, .\, \
  5. +, -
  6. :
  7. <, <=, ==, >=, >, ~=
  8. &
  9. |
  10. &&
  11. ||
Link to original

Matlab Control Statements

Matlab Math

Matlab Graphics

Other