matlab_mistake
matlab_mistake,
a MATLAB code which
illustrates some simple but devious programming mistakes in MATLAB.
Licensing:
The information on this web page is distributed under the MIT license.
Languages:
matlab_mistake is available in
a C version and
a Fortran77 version and
a Fortran90 version and
a MATLAB version and
an Octave version and
a Python version.
Source Code:
-
matlab_mistake_test01.m,
we put numbers in an array, except they don't seem to get there!
-
matlab_mistake_test02.m,
we try to create the -1, 2, -1 tridiagonal matrix but...we don't!
-
matlab_mistake_test03.m,
we try to create the array [ cos ( alpha ), sin ( alpha ) ] but...we can't!
-
matlab_mistake_test04.m,
the command "abs x" seems to work...almost.
-
matlab_mistake_test05.m,
variations of the command "B=1./A" can fail.
-
matlab_mistake_test06.m,
v = rand(3) is NOT a 3-vector.
-
matlab_mistake_test07.m,
"elseif" and "else if" are NOT equivalent!
Last revised on 06 November 2026.