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

358        Process Modelling and Simulation with Finite Element Methods
          >>  a=[O: 0.1: 1l*pi
          a=
            Columns 1 through 8
          0   0.3142   0.6283   0,9425  1.2566  1.5708   1.8850   2.1991
          Columns 9 through 11
          2.5133   2.8274   3 I 1416
          which produces eleven values equally spaced between 0 and K.  So does
          a=linspace (O,pi,11)
          a=
            Columns 1 through 8
          0   0.3142   0.6283  0.9425   1.2566   1.5708  1.8850  2.1991
          columns 9 through 11
          2.5133   2.8274    3.1416
          1 inspace is a versatile command for automatic matrix generation, performing
          a role that is often done in looping constructs in older programming languages.
          >>  help linspace
           LINSPACE Linearly spaced vector.
             LINSPACE(X1, X2) generates a row vector of 100 linearly
              equally spaced points between X1 and X2.
              LINSPACE(X1, X2, N) generates N points between X1 and X2.
              For N <  2, LINSPACE returns X2.
              See also LOGSPACE, :.
          logspace comes in handy as well.
          >>  help logspace
          LOGSPACE Logarithmically spaced vector.
              LOGSPACE(X1, X2) generates a row vector of 50 logarithmically
              equally spaced points between decades 1O*X1 and 10AX2.  If X2
              is pi, then the points are between 10AX1 and pi.
             LOGSPACE(X1, X2, N) generates N points.
              For N <  2, LOGSPACE returns lO"X2.
              See also LINSPACE, :.
          Four other common array generators are zeros, ones, rand, and for matrices,
          eye.  zeros initializes  an  array  with  zeros;  ones  with  ones,  rand with
          uniformly distributed random numbers (randn with normal deviates) and  eye
          with the identity matrix.
          >>  help zeros
           ZEROS  Zeros array.
             ZEROS(N) is an N-by-N matrix of zeros.
             ZEROS(M,N) or ZEROS( [M,N]  is an M-by-N matrix of zeros.
                                     )
             ZEROS (M,N,P,  . . .)  or ZEROS (  [M N P . . .I )  is an M-by-N-by-P-by-. .
             array of zeros.
             ZEROS(SIZE(A)) is the same size as A and all zeros.
          >>  help ones
          ONES   Ones array.
             ONES(N) is an N-by-N matrix of ones.
             ONES(M,N) or ONES([M,NI) is an M-by-N matrix of ones.
             ONES(M,N,P,  ... )  or ONES([M N P ... I)  is an M-by-N-by-P-by-..
             array  of ones.
             ONES(SIZE(A)) is the same size as A and all ones.
   366   367   368   369   370   371   372   373   374   375   376