Free Online Course in Programming - Matlab and Octave

Taking this course, one can easy learn how to use Octave and Matlab software and write your own programs. This programming languages are object-oriented and based on elementary algebra (vector and matrix objects). Thus, during that course one can learn also elementary math, mostly algebra.

Matlab and Octave Course - Content

  1. Elementary Commands
  2. Work With M-File
  3. Vectors and Matrices
  4. Logical Operators
  5. Conditional Instructions
  6. Loops
  7. Matrix Equations
    • Elementary
    • Gauss Elimination Method
    • Cholesky Factorisation
    • Least Squares Problem
  8. 2D Graphical Data Representation
    • Elementary
    • Subplot
  9. Complex Numbers
  10. Polynomials
  11. Functions
    • Script Functions
    • Anonymous Functions
    • Inline Functions
      • Easy Plots
  12. Other MATLAB/Octave Data Types
  13. Multi – Dimensional Arrays
  14. Errors
  15. Warnings
  16. Dialog Windows (MATLAB)
  17. UI Objects (MATLAB)
  18. 3D Graphical Data Representation
    • Graphics 3D
    • Trimesh and Delaunay Triangulation
  19. Animation
  20. Sound Effects
    • FFT
  21. Some Mathematical Problems
    • The Newton Algorithm
    • Discrete Mapping
    • Numerical Differentiation
    • Numerical Integration
      • Simulink

To get access to this free online course create your account on the taketechease:

If you already have one just Log In.
One can find below a piece of this course.

Vectors and Matrices

Run Octave or MATLAB.

Generation

  1. Vector is a mathematical object usually used to describe a point position. In n – dimensional space it has the structure: a = [a1, a2, a3, …, an] where ai denotes the i-th coordinate of a being the vector projection on the i-th direction. As programmers we do not care of its pure mathematical meaning. For us it is a set of numbers written either in a single row or in a single column. The calculus (rules how to operate on vectors) is also defined. Using vectors make our programs much simpler.
    In MATLAB/Octave to make a vector : operator is used. Let's create a vector
    • a = i:n gives the row vector a = [i, i+1, ..., n] with the step k = 1
    • when i>n we get the empty vector
    • a = i:k:n makes the vector with the step k and the last value i + k*fix((n-1)/k) the function fix(l) returns the nearest integer number to l towards 0
    • when k < 0 we get the vector of decaying values
    • to get the column vector b transpose a vector b = a'
    • vector dimension is defined by its length; to get length of a use length(a) function (one can use also size(a) function defined below)
    • a scalar is a vector of 1 × 1 size
  2. Matrix is a mathematical object being a table with numbers. To describe its dimension number of rows (e. g. n) and columns (e. g. m) must be given. Thus the size of matrix is defined by the pair of numbers n × m. The number of rows is called dimension 1 and the number of column is called dimension 2. This is the simplest form of a table containing numbers. However, tables can have more than 2 dimensions. Then their sizes are described by a set of numbers: n × m × l × …
  3. Getting elements of matrix or vector.
  4. A(:) makes one column vector from A matrix by putting all columns (from first to the last) from the matrix A in one column vector.
  5. A(i:n) makes one row vector from A matrix by putting elements from the i-th to the n-th from the matrix A in one row. Elements in a table are enumerated along columns as they form the column vector described above.
The m-file with exercises.

Operations

  1. to transpose A matrix (or vector) use A' or transpose(A) function
  2. to multiply two matrices A and B the number of columns of the first one should equal to the number of rows of the second one: A * B
  3. .* denotes matrices multiplication. The result of A.*B is a matrix of elements aij*bij, i. e. the elements of the A matrix are multiplied by the elements of B matrix, respectively. Both A and B must have the same sizes or one of them can be a scalar.
  4. when A is a square matrix A^n where n is a scalar denotes n-th power of A
  5. A.^n where n is a scalar gives the matrix of elements anij
  6. when A and C are matrices of the same size then A.^C is a matrix of elements aijcij
  7. when matrix A is square its determinant can be found: det(A)
  8. when matrix is square and their determinant differs from 0 then the inverse matrix to the A matrix exists and could be obtained by the inv(A) function
  9. if one needs to find the inverse matrix due to solve the equation
    inv(A) * B it is better to use the left division operator A \ B (it is true also for rectangular matrices under condition that A and B have the same number of rows; why? see below)
    A pseudo-inverse matrix Ag to the matrix A of n × m size is any matrix of the m × n size which fulfilled the following condition:
    A AgA = A
    but the pseudo-inverse matrix Ah to the matrix A of n × m size is the matrix of the m × n size which fulfilled the following conditions:
    A AhA = A
    Ah = U AT = AT V
    for matrices U of n × n and V of m × m.
    To compute the pseudo–inverse matrix one can make use of
    Lemma:
    If the matrix A ∈ ℜm×n has the rank r then it can be represented as product of two matrices B ∈ ℜm×r and C∈ℜr×n that have the rank r each
    A = BC
    rank B = rank C = r
  10. using the right division operator A / B is equivalent to the A * inv(B) (it is true also for rectangular matrices under condition that A and B have the same number of columns)
  11. adding two matrices: C = A + B means that cij = aij + bij where i = 1...n and j = 1...m
  12. subtract two matrices: C = A - B means that cij = aij - bij where i = 1...n and j = 1...m
  13. .\ denotes left matrices division. The result of A.\B is a matrix of elements bij/aij, i. e. the elements of the B matrix are divided by the elements of A matrix, respectively. Both A and B must have the same sizes or one of them can be a scalar.
  14. ./ denotes right matrices division. The result of A./B is a matrix of elements aij/bij, i. e. the elements of the A matrix are divided by the elements of B matrix, respectively. Both A and B must have the same sizes or one of them can be a scalar.
  15. to extract the upper triangular matrix from the A use triu(A) function
  16. to extract the lower triangular matrix from the A use tril(A) function
  17. to rotate the A matrix of 90 degrees use rot90(A) function
  18. to flip once the matrix A up and down use flipud(A) function
  19. to flip once the matrix A left and right use fliplr(A) function
  20. to flip the matrix along 1 or 2 dimension use flipdim(A, dim) function
  21. to replicate matrix A to get a block matrix BLOCK with size m by n use repmat(A, [m, n] ) function
  22. to form a new matrix from the A matrix with a new size m by n use reshape(A, m, n) function
The m-file with exercises.

Useful Functions

Assume that a is a vector
  1. prod(a) function gives the product of all vector elements
  2. sum(a) function gives the sum of all vector elements
  3. cumprod(a) function gives the vector of subsequent products of a elements
  4. cumsum(a) function gives the vector of subsequent sums of a elements
The m-file with exercises.
SHARE
Last update: February 21, 2018
© 2013-2018 taketechease.com Privacy Policy Terms of Use