Untitled

 avatar
unknown
matlab
5 months ago
3.1 kB
2
Indexable
 v1 = [1 2 3 4]

v1 =

     1     2     3     4

>> v1 = [1, 2, 3, 4]

v1 =

     1     2     3     4

>> v2 = [5;5;7;8]

v2 =

     5
     5
     7
     8

>> v3 = [sqrt(10) pi^3]

v3 =

    3.1623   31.0063

>> M = [2 3 4;5 6 7; 8 9 10]

M =

     2     3     4
     5     6     7
     8     9    10

>> S = []

S =

     []

>> v1

v1 =

     1     2     3     4

>> v1(3)

ans =

     3

>> v1(3) = 7

v1 =

     1     2     7     4

>> v1(3) = []

v1 =

     1     2     4

>> v1+2

ans =

     3     4     6

>> v(2)+2
Unrecognized function or variable 'v'.
 
>> v1(2)+2

ans =

     4

>> M

M =

     2     3     4
     5     6     7
     8     9    10

>> M(2)(3)
Error: Indexing with parentheses '()' must appear as the last operation of a valid indexing expression.
 
>> M(2,3)

ans =

     7

>> M(3,1)

ans =

     8

>> M([1 2 3], 1)

ans =

     2
     5
     8

>> 2:9

ans =

     2     3     4     5     6     7     8     9

>> 2:1:9

ans =

     2     3     4     5     6     7     8     9

>> 0:pi/4:pi

ans =

         0    0.7854    1.5708    2.3562    3.1416

>> 100:-7:75

ans =

   100    93    86    79

>> 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 = 1, linspace returns X2.
 
    Class support for inputs X1,X2:
       float: double, single
 
    See also logspace, colon.

    Documentation for linspace
    Other functions named linspace

>> linspace(0,100,5)

ans =

     0    25    50    75   100

>> linspace(0,100)

ans =

  Columns 1 through 13

         0    1.0101    2.0202    3.0303    4.0404    5.0505    6.0606    7.0707    8.0808    9.0909   10.1010   11.1111   12.1212

  Columns 14 through 26

   13.1313   14.1414   15.1515   16.1616   17.1717   18.1818   19.1919   20.2020   21.2121   22.2222   23.2323   24.2424   25.2525

  Columns 27 through 39

   26.2626   27.2727   28.2828   29.2929   30.3030   31.3131   32.3232   33.3333   34.3434   35.3535   36.3636   37.3737   38.3838

  Columns 40 through 52

   39.3939   40.4040   41.4141   42.4242   43.4343   44.4444   45.4545   46.4646   47.4747   48.4848   49.4949   50.5051   51.5152

  Columns 53 through 65

   52.5253   53.5354   54.5455   55.5556   56.5657   57.5758   58.5859   59.5960   60.6061   61.6162   62.6263   63.6364   64.6465

  Columns 66 through 78

   65.6566   66.6667   67.6768   68.6869   69.6970   70.7071   71.7172   72.7273   73.7374   74.7475   75.7576   76.7677   77.7778

  Columns 79 through 91

   78.7879   79.7980   80.8081   81.8182   82.8283   83.8384   84.8485   85.8586   86.8687   87.8788   88.8889   89.8990   90.9091

  Columns 92 through 100

   91.9192   92.9293   93.9394   94.9495   95.9596   96.9697   97.9798   98.9899  100.0000

>> M(:,1)

ans =

     2
     5
     8
Editor is loading...
Leave a Comment