09-Feb-2019 10:03:14

matlab_mistake_test
  MATLAB version
  Test matlab_mistake.

MATLAB_MISTAKE_TEST01:
  Set X(I) = 1 / ( I - 5 ) for I = 1 to 10
  but set X(5) to zero.

  Now let's print out X!

  X(1) = 0.000000
  X(2) = 0.000000
  X(3) = 0.000000
  X(4) = 0.000000
  X(5) = 99.000000
  X(6) = 0.000000
  X(7) = 0.000000
  X(8) = 0.000000
  X(9) = 0.000000
  X(10) = 0.000000

  That was NOT what we expected!

  Now let's print out X!

  X(1) = 0.000000
  X(2) = 0.000000
  X(3) = 0.000000
  X(4) = 0.000000
  X(5) = 99.000000
  X(6) = 0.000000
  X(7) = 0.000000
  X(8) = 0.000000
  X(9) = 0.000000
  X(10) = 0.000000

  That was NOT what we expected!

  Now let's print out X!

  X(1) = -0.250000
  X(2) = -0.333333
  X(3) = -0.500000
  X(4) = -1.000000
  X(5) = 99.000000
  X(6) = 1.000000
  X(7) = 0.500000
  X(8) = 0.333333
  X(9) = 0.250000
  X(10) = 0.200000

  By this time, the right answer is NOT what we expected!

  Now let's print out X!

  X(1) = 1.000000
  X(2) = 1.000000
  X(3) = 1.000000
  X(4) = 1.000000
  X(5) = 99.000000
  X(6) = 1.000000
  X(7) = 1.000000
  X(8) = 1.000000
  X(9) = 1.000000
  X(10) = 1.000000

  Now we see that the assignment statement is not assigning x(i)!

MATLAB_MISTAKE_TEST02:
  Try to create the -1, 2, -1 tridiagonal matrix.
a =

   2   0   0   0   0
   0   0   0   0   0
   0   0   0   0   0
   0   0   0   0   0
   0   0   0   0   0


MATLAB_MISTAKE_TEST03:
  v = [ cos ( alpha ), sin ( alpha ) ] fails.
alpha =  1.0472
v1 =

   0.50000   0.86603

ca =  0.50000
sa =  0.86603
v2 =

   0.50000   0.86603


  The statement "v3 = [ cos ( alpha ), sin ( alpha ) ]"
  will cause a MATLAB error:
  Error using cos.  Not enough input arguments.

MATLAB_MISTAKE_TEST04:
  y = abs x fails.
x =  123.46
ans =  123.46
ans =  120
ans =

    98    97   110    97   110    97


MATLAB_MISTAKE_TEST05:
  Versions of 1./A.
B =

   0.50000   1.00000
  -1.00000   0.50000

C =

   0.50000   1.00000
  -1.00000   0.50000


  "D = 1. / A" will cause a crash.
  So we suppress it.

MATLAB_MISTAKE_TEST06:
  v=rand(3) does NOT return a vector.
  So vdotv-v'*v does NOT return a scalar!

  v = rand ( 3 )  %  NOT a 3-vector!
v =

   0.39630   0.51794   0.89221
   0.65535   0.81646   0.87684
   0.55114   0.97849   0.75911


  vdotv = v'*v  %  NOT a scalar!
vdotv =

   0.89029   1.27960   1.34659
   1.27960   1.89230   1.92080
   1.34659   1.92080   2.14115


matlab_mistake_test
  Normal end of execution.

09-Feb-2019 10:03:14