Page 372 - Process Modelling and Simulation With Finite Element Methods
P. 372

A MATLAB/FEMLAB Primer for Vector Calculus    359

          >>  help rand
           RAND   Uniformly distributed random numbers.
             RAND(N) is an N-by-N matrix with random entries, chosen from
             a uniform distribution on the interval  (0.0,l.O).
             RAND(M,N) and RAND( [M,NI) are M-by-N matrices with random entries.
             RAND (M,N, P, . . . )  or RAND (  [M,N, P, . . .I )  generate random arrays.
             RAND with no arguments is a scalar whose value changes each time it
             is referenced.  RAND(SIZE(A)) is the same size as A.
          >>  help eye
           EYE Identity matrix.
              EYE(N) is the N-by-N identity matrix.
             EYE(M,N) or EYE( [M,N]) is an M-by-N matrix with 1's on
              the diagonal and zeros elsewhere.

              EYE(SIZE(A)) is the same size as A.
          Scalar - Array Math

          Arithmetic of scalars acting on arrays threads across the array.  For instance,
          >>  3*a
          ans =
          Columns 1 through 8
          0   0.9425   1.8850   2.8274   3.7699   4.7124   5.6549   6.5973
          Columns 9 through 11
          7.5398   8.4823    9.4248
          >>  5+a
          ans =
          Columns 1 through 8
          5.0000  5.3142  5.6283  5.9425  6.2566  6.5708  6.8850  7.1991
          Columns 9 through 11
          7.5133  7.8274  8.1416
          Array - Array Element- Wise Math

          Arithmetic of arrays on arrays is a tricky area.  If the arrays are compatible sizes,
          then dot-operators are applied element-wise:
          >>  b=linspace (1,11,11)
          b=
               1    2     3     4     5     6    7     8     9    10    11
          >>  size(a)
          ans =
               1   11
          >>  size(b)
          ans =
               1    11
          >>  a.*b
          ans =
          Columns 1 through 8
          0   0.6283   1.8850   3.7699   6.2832   9.4248   13.1947   17.5929
          columns 9 through 11
          22.6195  28.2743   34.5575
   367   368   369   370   371   372   373   374   375   376   377