Plots and GUI
- Loops, branches, and control-flow
The MATLAB code has its own instructions for flow of control statements
'while' and 'if-elseif' branching. See details
loop repeats a group of statements a fixed, predetermined number of
times. A matching end
delineates the statements...
of Nested Iterations (Matrix Multiplication)
We show a script in Matlab code that performs a matrix
multiplication step-by-step. The algorithm
displays all the
elements being considered for
the multiplication and shows how the
resulting matrix is being formed in each step. Obviously, Matlab can do
it with just one operation, but...
Let's calculate the coefficients of binomial expansions...
number (sometimes called also narcissistic numbers)
of three digits is an integer such that
the sum of the cubes of its digits equals the number itself. For
is an Armstrong number since 4^3 + 0^3 + 7^3 = 407...
loop repeats a group of statements an indefinite number of times
under control of a logical condition. A matching end closes the
Root (using while-loops)
explore a square
root algorithm as an excuse to use
in our numerical software. We’re not going to use the built-in
Collatz Sequence (while-loops)
The Collatz conjecture is
conjecture in mathematics. This conjecture is also known
as 3n + 1 or
problem; the sequence of numbers involved is referred to
as the hailstone
else... end (branches or decisions)
statement evaluates a logical expression and executes a group of
statements when the expression is true.
The optional elseif
keywords provide for the execution of alternate groups of statements...
(exit from loops)
statement lets you exit early from a for or while loop. In nested
exits from the innermost loop only...
Flow: for-loops, if-statements, break (in a Matrix Inversion)
This program performs the matrix
inversion of a square matrix
step-by-step. The inversion is performed by a modified Gauss-Jordan elimination
method. We start with an arbitrary square matrix and a same-size
identity matrix (all the elements along its diagonal are 1)...
statement executes groups of statements based on the value of a
variable or expression. The keywords case and otherwise delineate
function (or piecewise-defined function)
is a function whose definition changes depending on the value of the
Equation of Straight lines
three functions to work out
straight lines in Matlab with different approaches...
'Matlab Code' to home