clc
A

A =

     1     1     1
     3     4     5
     2     9     0
     3     4     5

clear
A
{Unrecognized function or variable 'A'.
} 
help transpose
 .' Transpose.
    X.' is the non-conjugate transpose.
 
    B = <strong>transpose</strong>(A) is called for the syntax A.' when A is an object.
 
    See <a href="matlab:helpview('matlab','MATLAB_OPS')">MATLAB Operators and Special Characters</a> for more details.
 
    See also <a href="matlab:help ctranspose -displayBanner">ctranspose</a>, <a href="matlab:help permute -displayBanner">permute</a>, <a href="matlab:help pagetranspose -displayBanner">pagetranspose</a>.

    <a href="matlab:doc transpose">Documentation for transpose</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('transpose')">Other uses of transpose</a>

Z = zeros(5)

Z =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

Z = zeros(7, 3)

Z =

     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0

N = ones(6)

N =

     1     1     1     1     1     1
     1     1     1     1     1     1
     1     1     1     1     1     1
     1     1     1     1     1     1
     1     1     1     1     1     1
     1     1     1     1     1     1

E = eye(3)

E =

     1     0     0
     0     1     0
     0     0     1

M = magic(3)

M =

     8     1     6
     3     5     7
     4     9     2

M1 = magic(4)

M1 =

    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

help magic
 <strong>magic</strong>  Magic square.
    <strong>magic</strong>(N) is an N-by-N matrix constructed from the integers
    1 through N^2 with equal row, column, and diagonal sums.
    Produces valid magic squares for all N > 0 except N = 2.

    <a href="matlab:doc magic">Documentation for magic</a>

d = diag(M1)

d =

    16
    11
     6
     1

d2 = d'

d2 =

    16    11     6     1

D = diag([1 2 3 4 5 6])

D =

     1     0     0     0     0     0
     0     2     0     0     0     0
     0     0     3     0     0     0
     0     0     0     4     0     0
     0     0     0     0     5     0
     0     0     0     0     0     6

help diag
 <strong>diag</strong> Diagonal matrices and diagonals of a matrix.
    <strong>diag</strong>(V,K) when V is a vector with N components is a square matrix
    of order N+ABS(K) with the elements of V on the K-th diagonal. K = 0
    is the main diagonal, K > 0 is above the main diagonal and K < 0
    is below the main diagonal. 
 
    <strong>diag</strong>(V) is the same as <strong>diag</strong>(V,0) and puts V on the main diagonal.
 
    <strong>diag</strong>(X,K) when X is a matrix is a column vector formed from
    the elements of the K-th diagonal of X.
 
    <strong>diag</strong>(X) is the main diagonal of X. <strong>diag</strong>(<strong>diag</strong>(X)) is a diagonal matrix.
 
    Example
       m = 5;
       diag(-m:m) + diag(ones(2*m,1),1) + diag(ones(2*m,1),-1)
    produces a tridiagonal matrix of order 2*m+1.
 
    See also <a href="matlab:help spdiags -displayBanner">spdiags</a>, <a href="matlab:help triu -displayBanner">triu</a>, <a href="matlab:help tril -displayBanner">tril</a>, <a href="matlab:help blkdiag -displayBanner">blkdiag</a>.

    <a href="matlab:doc diag">Documentation for diag</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('diag')">Other uses of diag</a>

D1 = diag([1 2 3 4 5 6], 2)

D1 =

     0     0     1     0     0     0     0     0
     0     0     0     2     0     0     0     0
     0     0     0     0     3     0     0     0
     0     0     0     0     0     4     0     0
     0     0     0     0     0     0     5     0
     0     0     0     0     0     0     0     6
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0

D2 = diag([1 2 3 4 5 6], -1)

D2 =

     0     0     0     0     0     0     0
     1     0     0     0     0     0     0
     0     2     0     0     0     0     0
     0     0     3     0     0     0     0
     0     0     0     4     0     0     0
     0     0     0     0     5     0     0
     0     0     0     0     0     6     0

E

E =

     1     0     0
     0     1     0
     0     0     1

M

M =

     8     1     6
     3     5     7
     4     9     2

E + M

ans =

     9     1     6
     3     6     7
     4     9     3

M - E

ans =

     7     1     6
     3     4     7
     4     9     1

A1 = ones(3)

A1 =

     1     1     1
     1     1     1
     1     1     1

A2 = diag([1 2 3])

A2 =

     1     0     0
     0     2     0
     0     0     3

A = A1 + A2

A =

     2     1     1
     1     3     1
     1     1     4

R = rand(6)

R =

    0.8147    0.2785    0.9572    0.7922    0.6787    0.7060
    0.9058    0.5469    0.4854    0.9595    0.7577    0.0318
    0.1270    0.9575    0.8003    0.6557    0.7431    0.2769
    0.9134    0.9649    0.1419    0.0357    0.3922    0.0462
    0.6324    0.1576    0.4218    0.8491    0.6555    0.0971
    0.0975    0.9706    0.9157    0.9340    0.1712    0.8235

help rand
 <strong>rand</strong> Uniformly distributed pseudorandom numbers.
    R = <strong>rand</strong>(N) returns an N-by-N matrix containing pseudorandom values drawn
    from the standard uniform distribution on the open interval(0,1).  <strong>rand</strong>(M,N)
    or <strong>rand</strong>([M,N]) returns an M-by-N matrix.  <strong>rand</strong>(M,N,P,...) or
    <strong>rand</strong>([M,N,P,...]) returns an M-by-N-by-P-by-... array.  <strong>rand</strong> returns a
    scalar.  <strong>rand</strong>(SIZE(A)) returns an array the same size as A.
 
    Note: The size inputs M, N, P, ... should be nonnegative integers.
    Negative integers are treated as 0.
 
    R = <strong>rand</strong>(..., CLASSNAME) returns an array of uniform values of the 
    specified class. CLASSNAME can be 'double' or 'single'.
 
    R = <strong>rand</strong>(..., 'like', Y) is an array of uniform values with the same
    data type and complexity (real or complex) as the numeric variable Y.
 
    The sequence of numbers produced by <strong>rand</strong> is determined by the settings of
    the uniform random number generator that underlies <strong>rand</strong>, RANDI, and RANDN.
    Control that shared random number generator using RNG.
 
    Examples:
 
       Example 1: Generate values from the uniform distribution on the
       interval (a, b).
          r = a + (b-a).*rand(100,1);
 
       Example 2: Use the RANDI function, instead of <strong>rand</strong>, to generate
       integer values from the uniform distribution on the set 1:100.
          r = randi(100,1,5);
 
       Example 3: Reset the random number generator used by <strong>rand</strong>, RANDI, and
       RANDN to its default startup settings, so that <strong>rand</strong> produces the same
       random numbers as if you restarted MATLAB.
          rng('default')
          rand(1,5)
 
       Example 4: Save the settings for the random number generator used by
       <strong>rand</strong>, RANDI, and RANDN, generate 5 values from <strong>rand</strong>, restore the
       settings, and repeat those values.
          s = rng
          u1 = rand(1,5)
          rng(s);
          u2 = rand(1,5) % contains exactly the same values as u1
 
       Example 5: Reinitialize the random number generator used by <strong>rand</strong>,
       RANDI, and RANDN with a seed based on the current time.  <strong>rand</strong> will
       return different values each time you do this.  NOTE: It is usually
       not necessary to do this more than once per MATLAB session.
          rng('shuffle');
          rand(1,5)
 
    See <a href="matlab:helpview([docroot '\techdoc\math\math.map'],'update_random_number_generator')">Replace Discouraged Syntaxes of rand and randn</a> to use RNG to replace
    <strong>rand</strong> with the 'seed', 'state', or 'twister' inputs.
 
    See also <a href="matlab:help randi -displayBanner">randi</a>, <a href="matlab:help randn -displayBanner">randn</a>, <a href="matlab:help rng -displayBanner">rng</a>, <a href="matlab:help RandStream -displayBanner">RandStream</a>, <a href="matlab:help RandStream/rand -displayBanner">RandStream/rand</a>,
             <a href="matlab:help sprand -displayBanner">sprand</a>, <a href="matlab:help sprandn -displayBanner">sprandn</a>, <a href="matlab:help randperm -displayBanner">randperm</a>.

    <a href="matlab:doc rand">Documentation for rand</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('rand')">Other uses of rand</a>

R = rand(6)

R =

    0.6948    0.7655    0.7094    0.1190    0.7513    0.5472
    0.3171    0.7952    0.7547    0.4984    0.2551    0.1386
    0.9502    0.1869    0.2760    0.9597    0.5060    0.1493
    0.0344    0.4898    0.6797    0.3404    0.6991    0.2575
    0.4387    0.4456    0.6551    0.5853    0.8909    0.8407
    0.3816    0.6463    0.1626    0.2238    0.9593    0.2543

N2 = randn(3)

N2 =

    0.7481   -0.7648    0.4882
   -0.1924   -1.4023   -0.1774
    0.8886   -1.4224   -0.1961

mean(N2)

ans =

    0.4814   -1.1965    0.0383

u = randn(1, 4)

u =

    1.4193    0.2916    0.1978    1.5877

mean(u)

ans =

    0.8741

u100 = randn(1, 100)

u100 =

  Columns 1 through 8

   -0.8045    0.6966    0.8351   -0.2437    0.2157   -1.1658   -1.1480    0.1049

  Columns 9 through 16

    0.7223    2.5855   -0.6669    0.1873   -0.0825   -1.9330   -0.4390   -1.7947

  Columns 17 through 24

    0.8404   -0.8880    0.1001   -0.5445    0.3035   -0.6003    0.4900    0.7394

  Columns 25 through 32

    1.7119   -0.1941   -2.1384   -0.8396    1.3546   -1.0722    0.9610    0.1240

  Columns 33 through 40

    1.4367   -1.9609   -0.1977   -1.2078    2.9080    0.8252    1.3790   -1.0582

  Columns 41 through 48

   -0.4686   -0.2725    1.0984   -0.2779    0.7015   -2.0518   -0.3538   -0.8236

  Columns 49 through 56

   -1.5771    0.5080    0.2820    0.0335   -1.3337    1.1275    0.3502   -0.2991

  Columns 57 through 64

    0.0229   -0.2620   -1.7502   -0.2857   -0.8314   -0.9792   -1.1564   -0.5336

  Columns 65 through 72

   -2.0026    0.9642    0.5201   -0.0200   -0.0348   -0.7982    1.0187   -0.1332

  Columns 73 through 80

   -0.7145    1.3514   -0.2248   -0.5890   -0.2938   -0.8479   -1.1201    2.5260

  Columns 81 through 88

    1.6555    0.3075   -1.2571   -0.8655   -0.1765    0.7914   -1.3320   -2.3299

  Columns 89 through 96

   -1.4491    0.3335    0.3914    0.4517   -0.1303    0.1837   -0.4762    0.8620

  Columns 97 through 100

   -1.3617    0.4550   -0.8487   -0.3349

mean(u100)

ans =

   -0.1512

I = randi(4)

I =

     3

I = randi(4, 30, 50)

I =

  Columns 1 through 14

     4     1     1     3     3     2     1     1     2     2     3     1     3     4
     1     2     2     1     1     2     4     1     4     1     2     1     2     4
     4     2     4     1     3     4     3     2     3     1     2     2     3     3
     4     4     3     3     3     4     2     1     4     3     3     2     2     4
     2     2     3     3     4     1     1     3     3     2     4     2     3     3
     2     1     1     2     3     3     2     2     4     1     2     4     3     1
     2     4     2     4     4     2     2     3     1     2     3     3     2     1
     2     4     3     3     2     2     1     3     3     3     2     4     1     2
     3     2     3     3     2     3     3     3     2     1     4     4     2     3
     3     1     2     4     4     4     1     1     3     3     4     4     2     4
     4     2     2     4     1     2     2     1     3     1     2     1     2     4
     4     2     4     3     1     4     3     2     1     4     3     1     1     2
     3     3     1     1     1     2     2     3     2     2     3     3     4     3
     2     2     4     1     2     3     2     3     1     4     3     1     2     1
     4     3     4     4     4     3     3     2     3     1     4     3     4     1
     3     3     4     1     4     3     2     4     4     2     2     3     2     1
     2     1     1     2     1     3     4     3     2     1     2     4     4     3
     4     1     2     1     2     3     4     4     4     3     1     2     2     2
     4     2     2     4     3     1     3     3     3     3     4     2     4     1
     3     2     3     3     2     1     2     2     1     3     3     3     4     2
     3     2     1     3     3     4     3     1     3     2     2     3     2     1
     3     3     3     2     3     1     1     3     2     3     3     3     1     1
     1     1     1     1     2     1     4     4     4     3     3     2     4     4
     2     2     3     3     2     3     4     2     1     3     3     1     4     3
     2     4     2     1     1     4     4     1     2     3     3     3     2     4
     1     1     4     1     4     3     2     2     2     4     3     2     3     3
     4     4     3     3     1     1     3     1     2     1     3     1     2     3
     1     3     4     1     1     2     1     2     4     3     4     4     4     4
     1     2     4     4     2     2     2     2     2     1     1     1     4     4
     1     3     2     4     1     4     2     3     4     1     1     2     1     4

  Columns 15 through 28

     1     4     2     1     3     3     1     3     2     1     2     1     1     1
     4     1     1     4     2     4     1     3     3     1     3     4     2     4
     3     3     4     3     4     3     3     4     1     1     1     4     1     3
     4     3     1     4     1     1     2     2     4     1     2     3     4     2
     3     1     1     2     3     1     4     1     1     1     1     3     3     4
     2     3     1     2     3     4     4     1     2     1     4     1     4     1
     4     2     1     1     3     4     3     4     4     2     4     3     1     3
     1     1     3     1     1     3     1     1     2     2     2     2     4     3
     2     2     3     3     3     1     1     2     4     1     3     1     4     2
     4     1     1     2     2     4     1     3     2     2     2     1     3     1
     3     1     4     4     1     2     4     1     2     4     3     4     2     1
     4     1     3     1     1     2     4     3     1     3     4     1     2     2
     3     1     3     4     4     3     3     2     3     3     3     1     4     1
     3     1     1     3     1     1     1     1     2     1     2     3     1     3
     1     1     4     3     1     1     3     4     2     1     2     4     1     2
     3     3     4     4     1     3     1     1     3     1     2     3     4     4
     1     2     4     2     2     3     1     2     1     4     2     3     3     3
     3     3     4     2     1     3     3     1     2     3     2     1     3     3
     3     3     4     2     4     3     2     3     4     3     3     4     3     1
     3     2     3     4     1     3     3     1     3     2     3     3     2     4
     4     3     1     4     1     4     3     2     1     1     2     3     2     2
     4     2     2     1     2     2     3     1     1     3     2     1     4     4
     4     1     1     1     2     3     3     1     1     4     1     4     2     1
     3     2     1     2     1     3     1     4     1     1     1     3     4     2
     4     4     4     1     4     2     3     2     2     2     2     1     4     1
     3     4     2     3     2     1     4     3     3     2     2     3     4     3
     1     2     2     2     2     4     4     4     3     1     3     2     3     1
     1     1     2     1     1     2     1     2     3     3     4     3     3     1
     4     3     2     1     2     3     2     3     1     2     4     2     4     3
     2     3     3     4     1     3     2     4     3     4     2     2     2     2

  Columns 29 through 42

     3     4     3     4     4     2     1     4     3     3     1     2     1     4
     2     3     4     4     4     3     3     1     1     1     2     2     2     3
     3     1     2     1     3     2     3     2     1     2     2     3     4     2
     1     1     4     1     3     1     3     1     3     3     3     3     2     2
     4     1     2     1     2     3     2     1     2     4     2     4     3     2
     4     1     4     2     4     3     3     3     4     4     4     3     4     4
     3     1     2     1     1     3     4     3     4     2     4     2     4     3
     4     3     2     4     3     3     1     4     2     4     2     4     4     2
     2     4     1     1     3     1     1     3     4     2     2     1     1     3
     3     2     1     1     4     2     4     1     4     4     3     1     2     4
     3     2     2     3     2     2     3     4     3     4     4     1     4     4
     3     4     3     4     3     1     1     4     4     4     3     1     3     3
     2     4     4     2     4     3     2     2     4     2     3     2     3     1
     1     3     3     1     2     4     1     3     3     2     2     2     3     2
     2     4     1     2     3     2     2     4     3     1     2     1     4     3
     1     4     4     1     4     3     2     3     3     4     3     3     3     2
     4     2     4     3     3     1     2     4     1     4     4     1     1     1
     4     3     4     4     2     4     1     2     2     4     3     1     2     1
     1     1     1     3     3     1     2     2     3     3     1     3     2     4
     3     2     2     1     2     3     1     3     3     3     3     4     4     1
     1     3     3     2     4     2     4     2     2     1     2     4     3     4
     4     3     3     1     2     4     1     3     4     4     2     3     3     1
     4     2     1     3     2     3     4     3     4     2     1     4     3     3
     1     3     2     2     3     2     2     3     4     1     4     3     2     3
     4     4     3     4     4     4     1     2     2     4     2     3     3     1
     1     3     2     4     2     2     2     1     3     4     1     2     3     3
     3     3     3     2     4     2     3     2     4     4     2     2     1     1
     4     3     1     4     3     4     4     2     4     2     2     2     3     3
     3     3     1     1     4     1     3     4     3     3     3     1     3     3
     4     1     4     2     1     4     3     4     1     3     3     4     2     1

  Columns 43 through 50

     1     3     2     1     1     1     4     1
     1     2     3     3     3     1     1     4
     1     4     1     3     2     3     1     3
     2     3     4     3     1     2     2     3
     4     2     1     3     1     3     4     1
     3     4     2     1     1     2     2     1
     3     3     1     4     4     1     2     2
     4     3     1     1     4     3     1     4
     1     3     1     2     4     2     2     4
     4     2     1     4     3     4     2     3
     1     1     1     4     1     4     1     3
     3     3     2     2     2     2     2     1
     1     4     1     2     1     1     1     3
     3     2     1     3     1     3     3     4
     1     1     3     4     2     4     1     2
     4     2     4     4     3     4     3     4
     4     2     4     3     3     1     4     1
     4     2     1     2     3     2     1     2
     4     4     2     4     2     3     2     3
     3     2     2     2     2     3     3     1
     2     2     3     4     3     3     1     3
     1     2     2     1     4     3     2     3
     3     1     1     3     4     3     3     3
     3     2     2     3     3     2     1     4
     4     1     1     1     3     3     4     4
     1     2     1     2     3     1     4     4
     3     2     4     1     1     1     4     2
     3     2     2     2     3     4     3     2
     1     2     4     2     2     2     2     4
     4     1     4     3     1     3     3     1

I = randi(4, 3, 5)

I =

     1     4     2     3     4
     2     3     4     2     3
     3     2     4     1     4

help randi
 <strong>randi</strong> Pseudorandom integers from a uniform discrete distribution.
    R = <strong>randi</strong>(IMAX,N) returns an N-by-N matrix containing pseudorandom
    integer values drawn from the discrete uniform distribution on 1:IMAX.
    <strong>randi</strong>(IMAX,M,N) or <strong>randi</strong>(IMAX,[M,N]) returns an M-by-N matrix.
    <strong>randi</strong>(IMAX,M,N,P,...) or <strong>randi</strong>(IMAX,[M,N,P,...]) returns an
    M-by-N-by-P-by-... array.  <strong>randi</strong>(IMAX) returns a scalar.
    <strong>randi</strong>(IMAX,SIZE(A)) returns an array the same size as A.
 
    R = <strong>randi</strong>([IMIN,IMAX],...) returns an array containing integer
    values drawn from the discrete uniform distribution on IMIN:IMAX.
 
    Note: The size inputs M, N, P, ... should be nonnegative integers.
    Negative integers are treated as 0.
 
    R = <strong>randi</strong>(..., CLASSNAME) returns an array of integer values of class
    CLASSNAME.
 
    R = <strong>randi</strong>(..., 'like', Y) returns an array of integer values with 
    the same data type and complexity (real or complex) as the numeric
    variable Y.
 
    The arrays returned by <strong>randi</strong> may contain repeated integer values.  This
    is sometimes referred to as sampling with replacement.  To get unique
    integer values, sometimes referred to as sampling without replacement,
    use RANDPERM.
 
    The sequence of numbers produced by <strong>randi</strong> is determined by the settings of
    the uniform random number generator that underlies RAND, RANDN, and <strong>randi</strong>.
    <strong>randi</strong> uses one uniform random value to create each integer random value.
    Control that shared random number generator using RNG.
 
    Examples:
 
       Example 1: Generate integer values from the uniform distribution on
       the set 1:10.
          r = randi(10,100,1);
 
       Example 2: Generate an integer array of integer values drawn uniformly
       from 1:10.
          r = randi(10,100,1,'uint32');
 
       Example 3: Generate integer values drawn uniformly from -10:10.
          r = randi([-10 10],100,1);
 
       Example 4: Reset the random number generator used by RAND, <strong>randi</strong>, and
       RANDN to its default startup settings, so that <strong>randi</strong> produces the same
       random numbers as if you restarted MATLAB.
          rng('default');
          randi(10,1,5)
 
       Example 5: Save the settings for the random number generator used by
       RAND, <strong>randi</strong>, and RANDN, generate 5 values from <strong>randi</strong>, restore the
       settings, and repeat those values.
          s = rng
          i1 = randi(10,1,5)
          rng(s);
          i2 = randi(10,1,5) % i2 contains exactly the same values as i1
 
       Example 6: Reinitialize the random number generator used by RAND,
       <strong>randi</strong>, and RANDN with a seed based on the current time.  <strong>randi</strong> will
       return different values each time you do this.  NOTE: It is usually
       not necessary to do this more than once per MATLAB session.
          rng('shuffle');
          randi(10,1,5)
 
    See also <a href="matlab:help rand -displayBanner">rand</a>, <a href="matlab:help randn -displayBanner">randn</a>, <a href="matlab:help randperm -displayBanner">randperm</a>, <a href="matlab:help rng -displayBanner">rng</a>, <a href="matlab:help RandStream -displayBanner">RandStream</a>

    <a href="matlab:doc randi">Documentation for randi</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('randi')">Other uses of randi</a>

I = randi([10, 20], 3, 5)

I =

    10    19    14    12    17
    16    12    19    13    16
    13    14    17    11    11

I = randi(10, 20, 3, 5)

I(:,:,1) =

     2     4     1
     5     3    10
    10     8     8
     6    10     6
     1     2     2
     1     8     5
     9     2     6
     5    10    10
     4     9     9
     8     5    10
     4     8     7
     6     5     5
     8     9    10
     9     4     5
     4     1     3
     7     6     4
    10    10     8
     1     2     6
     6     5     8
     5     8    10


I(:,:,2) =

    10     2     4
     6     3     6
    10     2    10
     2     2     8
     1     4     4
     4     9     8
     6     5    10
     6     5     6
    10     2     6
     6    10     4
     5     5     1
     6     9     2
     8     7     1
     1     4     5
     9     9     1
     2     8    10
     5     5     7
     3     9     1
     4     9     1
     7     5     3


I(:,:,3) =

     5     8     1
     2     4     7
     1     5     2
     8     7     5
     4    10     9
     8     2     6
     5     8     4
     5     6     3
     1     5     5
     1     9    10
     1     4     2
     6     2     5
     3     7     9
     9     7     1
     9     4     7
    10     9    10
     5    10     3
     3    10     2
     3     2     7
     6     3    10


I(:,:,4) =

     7    10     2
     9     9     2
     2     9     1
     8     6     4
     4     6     8
     5     9     3
     2     1     8
     9     9     7
     7     5     9
     8     1     9
     9     8     3
     1     2     4
    10     2     6
     5     7     4
     8     3     9
     8     4     9
     9     5     6
     2     5     3
     5     4     7
     7     7     3


I(:,:,5) =

     5     1     8
     4     8     4
     6     8     8
    10     6     9
     8     4     3
    10     9     2
     3     6     3
     6    10     4
     1     9     3
     8     4    10
     7     6     1
     9     4     6
    10     7     2
    10     8     9
     5     8     2
     1     2     6
     6     9    10
     3     1     4
     3     5     1
     4     8     3

I = randi((10, 20), 3, 5)
 I = randi((10, 20), 3, 5)
              ↑
{Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
} 
A1

A1 =

     1     1     1
     1     1     1
     1     1     1

M

M =

     8     1     6
     3     5     7
     4     9     2

A1 * M

ans =

    15    15    15
    15    15    15
    15    15    15

A1 .* M

ans =

     8     1     6
     3     5     7
     4     9     2

E

E =

     1     0     0
     0     1     0
     0     0     1

M

M =

     8     1     6
     3     5     7
     4     9     2

E .* M

ans =

     8     0     0
     0     5     0
     0     0     2

D

D =

     1     0     0     0     0     0
     0     2     0     0     0     0
     0     0     3     0     0     0
     0     0     0     4     0     0
     0     0     0     0     5     0
     0     0     0     0     0     6

E

E =

     1     0     0
     0     1     0
     0     0     1

D * E
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('mtimes')" style="font-weight:bold"> * </a>
Incorrect dimensions for matrix multiplication. Check that the number of columns in the
first matrix matches the number of rows in the second matrix. To operate on each
element of the matrix individually, use TIMES (.*) for elementwise multiplication.

<a href="matlab:helpview('matlab','error_innerdim')" style="font-weight:bold">Related documentation</a>
} 
D.*E
{Arrays have incompatible sizes for this operation.

<a href="matlab:helpview('matlab','error_sizeDimensionsMustMatch')" style="font-weight:bold">Related documentation</a>
} 
linspace(2, 1, 5)

ans =

    2.0000    1.7500    1.5000    1.2500    1.0000

linspace(1, 2, 6)

ans =

    1.0000    1.2000    1.4000    1.6000    1.8000    2.0000

linspace(2, 1, 6)

ans =

    2.0000    1.8000    1.6000    1.4000    1.2000    1.0000

help linspace
 <strong>linspace</strong> Linearly spaced vector.
    <strong>linspace</strong>(X1, X2) generates a row vector of 100 linearly
    equally spaced points between X1 and X2.
 
    <strong>linspace</strong>(X1, X2, N) generates N points between X1 and X2.
    For N = 1, <strong>linspace</strong> returns X2.
 
    Class support for inputs X1,X2:
       float: double, single
 
    See also <a href="matlab:help logspace -displayBanner">logspace</a>, <a href="matlab:help colon -displayBanner">colon</a>.

    <a href="matlab:doc linspace">Documentation for linspace</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('linspace')">Other uses of linspace</a>

linspace(1, 100)

ans =

  Columns 1 through 14

     1     2     3     4     5     6     7     8     9    10    11    12    13    14

  Columns 15 through 28

    15    16    17    18    19    20    21    22    23    24    25    26    27    28

  Columns 29 through 42

    29    30    31    32    33    34    35    36    37    38    39    40    41    42

  Columns 43 through 56

    43    44    45    46    47    48    49    50    51    52    53    54    55    56

  Columns 57 through 70

    57    58    59    60    61    62    63    64    65    66    67    68    69    70

  Columns 71 through 84

    71    72    73    74    75    76    77    78    79    80    81    82    83    84

  Columns 85 through 98

    85    86    87    88    89    90    91    92    93    94    95    96    97    98

  Columns 99 through 100

    99   100

linspace(1, 200)

ans =

  Columns 1 through 8

    1.0000    3.0101    5.0202    7.0303    9.0404   11.0505   13.0606   15.0707

  Columns 9 through 16

   17.0808   19.0909   21.1010   23.1111   25.1212   27.1313   29.1414   31.1515

  Columns 17 through 24

   33.1616   35.1717   37.1818   39.1919   41.2020   43.2121   45.2222   47.2323

  Columns 25 through 32

   49.2424   51.2525   53.2626   55.2727   57.2828   59.2929   61.3030   63.3131

  Columns 33 through 40

   65.3232   67.3333   69.3434   71.3535   73.3636   75.3737   77.3838   79.3939

  Columns 41 through 48

   81.4040   83.4141   85.4242   87.4343   89.4444   91.4545   93.4646   95.4747

  Columns 49 through 56

   97.4848   99.4949  101.5051  103.5152  105.5253  107.5354  109.5455  111.5556

  Columns 57 through 64

  113.5657  115.5758  117.5859  119.5960  121.6061  123.6162  125.6263  127.6364

  Columns 65 through 72

  129.6465  131.6566  133.6667  135.6768  137.6869  139.6970  141.7071  143.7172

  Columns 73 through 80

  145.7273  147.7374  149.7475  151.7576  153.7677  155.7778  157.7879  159.7980

  Columns 81 through 88

  161.8081  163.8182  165.8283  167.8384  169.8485  171.8586  173.8687  175.8788

  Columns 89 through 96

  177.8889  179.8990  181.9091  183.9192  185.9293  187.9394  189.9495  191.9596

  Columns 97 through 100

  193.9697  195.9798  197.9899  200.0000

linspace(1, 201)

ans =

  Columns 1 through 8

    1.0000    3.0202    5.0404    7.0606    9.0808   11.1010   13.1212   15.1414

  Columns 9 through 16

   17.1616   19.1818   21.2020   23.2222   25.2424   27.2626   29.2828   31.3030

  Columns 17 through 24

   33.3232   35.3434   37.3636   39.3838   41.4040   43.4242   45.4444   47.4646

  Columns 25 through 32

   49.4848   51.5051   53.5253   55.5455   57.5657   59.5859   61.6061   63.6263

  Columns 33 through 40

   65.6465   67.6667   69.6869   71.7071   73.7273   75.7475   77.7677   79.7879

  Columns 41 through 48

   81.8081   83.8283   85.8485   87.8687   89.8889   91.9091   93.9293   95.9495

  Columns 49 through 56

   97.9697   99.9899  102.0101  104.0303  106.0505  108.0707  110.0909  112.1111

  Columns 57 through 64

  114.1313  116.1515  118.1717  120.1919  122.2121  124.2323  126.2525  128.2727

  Columns 65 through 72

  130.2929  132.3131  134.3333  136.3535  138.3737  140.3939  142.4141  144.4343

  Columns 73 through 80

  146.4545  148.4747  150.4949  152.5152  154.5354  156.5556  158.5758  160.5960

  Columns 81 through 88

  162.6162  164.6364  166.6566  168.6768  170.6970  172.7172  174.7374  176.7576

  Columns 89 through 96

  178.7778  180.7980  182.8182  184.8384  186.8586  188.8788  190.8990  192.9192

  Columns 97 through 100

  194.9394  196.9596  198.9798  201.0000

linspace(1, 200)

ans =

  Columns 1 through 8

    1.0000    3.0101    5.0202    7.0303    9.0404   11.0505   13.0606   15.0707

  Columns 9 through 16

   17.0808   19.0909   21.1010   23.1111   25.1212   27.1313   29.1414   31.1515

  Columns 17 through 24

   33.1616   35.1717   37.1818   39.1919   41.2020   43.2121   45.2222   47.2323

  Columns 25 through 32

   49.2424   51.2525   53.2626   55.2727   57.2828   59.2929   61.3030   63.3131

  Columns 33 through 40

   65.3232   67.3333   69.3434   71.3535   73.3636   75.3737   77.3838   79.3939

  Columns 41 through 48

   81.4040   83.4141   85.4242   87.4343   89.4444   91.4545   93.4646   95.4747

  Columns 49 through 56

   97.4848   99.4949  101.5051  103.5152  105.5253  107.5354  109.5455  111.5556

  Columns 57 through 64

  113.5657  115.5758  117.5859  119.5960  121.6061  123.6162  125.6263  127.6364

  Columns 65 through 72

  129.6465  131.6566  133.6667  135.6768  137.6869  139.6970  141.7071  143.7172

  Columns 73 through 80

  145.7273  147.7374  149.7475  151.7576  153.7677  155.7778  157.7879  159.7980

  Columns 81 through 88

  161.8081  163.8182  165.8283  167.8384  169.8485  171.8586  173.8687  175.8788

  Columns 89 through 96

  177.8889  179.8990  181.9091  183.9192  185.9293  187.9394  189.9495  191.9596

  Columns 97 through 100

  193.9697  195.9798  197.9899  200.0000

linspace(1, 200)

ans =

  Columns 1 through 8

    1.0000    3.0101    5.0202    7.0303    9.0404   11.0505   13.0606   15.0707

  Columns 9 through 16

   17.0808   19.0909   21.1010   23.1111   25.1212   27.1313   29.1414   31.1515

  Columns 17 through 24

   33.1616   35.1717   37.1818   39.1919   41.2020   43.2121   45.2222   47.2323

  Columns 25 through 32

   49.2424   51.2525   53.2626   55.2727   57.2828   59.2929   61.3030   63.3131

  Columns 33 through 40

   65.3232   67.3333   69.3434   71.3535   73.3636   75.3737   77.3838   79.3939

  Columns 41 through 48

   81.4040   83.4141   85.4242   87.4343   89.4444   91.4545   93.4646   95.4747

  Columns 49 through 56

   97.4848   99.4949  101.5051  103.5152  105.5253  107.5354  109.5455  111.5556

  Columns 57 through 64

  113.5657  115.5758  117.5859  119.5960  121.6061  123.6162  125.6263  127.6364

  Columns 65 through 72

  129.6465  131.6566  133.6667  135.6768  137.6869  139.6970  141.7071  143.7172

  Columns 73 through 80

  145.7273  147.7374  149.7475  151.7576  153.7677  155.7778  157.7879  159.7980

  Columns 81 through 88

  161.8081  163.8182  165.8283  167.8384  169.8485  171.8586  173.8687  175.8788

  Columns 89 through 96

  177.8889  179.8990  181.9091  183.9192  185.9293  187.9394  189.9495  191.9596

  Columns 97 through 100

  193.9697  195.9798  197.9899  200.0000

help linspace
 <strong>linspace</strong> Linearly spaced vector.
    <strong>linspace</strong>(X1, X2) generates a row vector of 100 linearly
    equally spaced points between X1 and X2.
 
    <strong>linspace</strong>(X1, X2, N) generates N points between X1 and X2.
    For N = 1, <strong>linspace</strong> returns X2.
 
    Class support for inputs X1,X2:
       float: double, single
 
    See also <a href="matlab:help logspace -displayBanner">logspace</a>, <a href="matlab:help colon -displayBanner">colon</a>.

    <a href="matlab:doc linspace">Documentation for linspace</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('linspace')">Other uses of linspace</a>

N2

N2 =

    0.7481   -0.7648    0.4882
   -0.1924   -1.4023   -0.1774
    0.8886   -1.4224   -0.1961

M

M =

     8     1     6
     3     5     7
     4     9     2

Nova_matrica = [ N2 M ]

Nova_matrica =

    0.7481   -0.7648    0.4882    8.0000    1.0000    6.0000
   -0.1924   -1.4023   -0.1774    3.0000    5.0000    7.0000
    0.8886   -1.4224   -0.1961    4.0000    9.0000    2.0000

Nova_matrica2 = [ N2; M ]

Nova_matrica2 =

    0.7481   -0.7648    0.4882
   -0.1924   -1.4023   -0.1774
    0.8886   -1.4224   -0.1961
    8.0000    1.0000    6.0000
    3.0000    5.0000    7.0000
    4.0000    9.0000    2.0000

M1

M1 =

    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

M

M =

     8     1     6
     3     5     7
     4     9     2

[ M M1 ]
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('horzcat')" style="font-weight:bold">horzcat</a>
Dimensions of arrays being concatenated are not consistent.
} 
blkdiag(M, M1)

ans =

     8     1     6     0     0     0     0
     3     5     7     0     0     0     0
     4     9     2     0     0     0     0
     0     0     0    16     2     3    13
     0     0     0     5    11    10     8
     0     0     0     9     7     6    12
     0     0     0     4    14    15     1

blkdiag(M, M1, E)

ans =

     8     1     6     0     0     0     0     0     0     0
     3     5     7     0     0     0     0     0     0     0
     4     9     2     0     0     0     0     0     0     0
     0     0     0    16     2     3    13     0     0     0
     0     0     0     5    11    10     8     0     0     0
     0     0     0     9     7     6    12     0     0     0
     0     0     0     4    14    15     1     0     0     0
     0     0     0     0     0     0     0     1     0     0
     0     0     0     0     0     0     0     0     1     0
     0     0     0     0     0     0     0     0     0     1

M

M =

     8     1     6
     3     5     7
     4     9     2

M(2, 3)

ans =

     7

M(9)

ans =

     2

M(4)

ans =

     1

D1

D1 =

     0     0     1     0     0     0     0     0
     0     0     0     2     0     0     0     0
     0     0     0     0     3     0     0     0
     0     0     0     0     0     4     0     0
     0     0     0     0     0     0     5     0
     0     0     0     0     0     0     0     6
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0

D1(2, [3, 4, 5, 6])

ans =

     0     2     0     0

2 : 4 : 20

ans =

     2     6    10    14    18

2:20

ans =

  Columns 1 through 14

     2     3     4     5     6     7     8     9    10    11    12    13    14    15

  Columns 15 through 19

    16    17    18    19    20

D1(2, 3:6)

ans =

     0     2     0     0

D1(2, 3:500)
{Index in position 2 exceeds array bounds. Index must not exceed 8.
} 
D1(2:end, 3:end)

ans =

     0     2     0     0     0     0
     0     0     3     0     0     0
     0     0     0     4     0     0
     0     0     0     0     5     0
     0     0     0     0     0     6
     0     0     0     0     0     0
     0     0     0     0     0     0

numel(D1)

ans =

    64

Z

Z =

     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0

numel(Z)

ans =

    21

size(Z)

ans =

     7     3

vel = size(Z)

vel =

     7     3

vel1 = vel(1)

vel1 =

     7

vel1 = vel(2)

vel1 =

     3

M = [ 1 2 3 4; 5 6 7 8; 1 1 1 0]

M =

     1     2     3     4
     5     6     7     8
     1     1     1     0

d = det(M)
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('det')" style="font-weight:bold">det</a>
Matrix must be square.
} 
M = [ 1 2 3 4; 5 6 7 8; 1 1 1 0; 0 0 2 2]

M =

     1     2     3     4
     5     6     7     8
     1     1     1     0
     0     0     2     2

d = det(M)

d =

   -8.0000

N = [ 2 3; 0 5]

N =

     2     3
     0     5

det(N)

ans =

    10

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     0
     0     0     2     2

Mi = inv(M)

Mi =

   -1.7500    0.7500   -1.0000    0.5000
    1.5000   -0.5000    1.0000   -1.0000
    0.2500   -0.2500    1.0000    0.5000
   -0.2500    0.2500   -1.0000    0.0000

Mi * M

ans =

    1.0000         0    0.0000    0.0000
   -0.0000    1.0000   -0.0000   -0.0000
    0.0000    0.0000    1.0000    0.0000
   -0.0000   -0.0000   -0.0000    1.0000

M * Mi

ans =

    1.0000         0    0.0000   -0.0000
   -0.0000    1.0000   -0.0000   -0.0000
    0.0000         0    1.0000   -0.0000
         0         0         0    1.0000

M'

ans =

     1     5     1     0
     2     6     1     0
     3     7     1     2
     4     8     0     2

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     0
     0     0     2     2

transpose(M)

ans =

     1     5     1     0
     2     6     1     0
     3     7     1     2
     4     8     0     2

sum(M)

ans =

     7     9    13    14

m = sum(sum(M))

m =

    43

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     0
     0     0     2     2

sum(M)

ans =

     7     9    13    14

m = sum(sum(M))

m =

    43

sum([1 2 5 6])

ans =

    14

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     0
     0     0     2     2

M(3, end)

ans =

     0

M(3, end) = 1

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     0     0     2     2

M(end, [1 2])

ans =

     0     0

M(end, [1 2]) = [2 3]

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

prod(M)

ans =

    10    36    42    64

prod(prod(M))

ans =

      967680

cumsum(M)

ans =

     1     2     3     4
     6     8    10    12
     7     9    11    13
     9    12    13    15

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

cumsum(M)

ans =

     1     2     3     4
     6     8    10    12
     7     9    11    13
     9    12    13    15

cumprod(M)

ans =

     1     2     3     4
     5    12    21    32
     5    12    21    32
    10    36    42    64

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

min(M)

ans =

     1     1     1     1

max(M)

ans =

     5     6     7     8

min(min(M))

ans =

     1

max(max(M))

ans =

     8

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

trace(M)

ans =

    10

K = [1 2 3; 2 2 0]

K =

     1     2     3
     2     2     0

trace(K)
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('trace')" style="font-weight:bold">trace</a>
Matrix must be square.
} 
M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

tril(M)

ans =

     1     0     0     0
     5     6     0     0
     1     1     1     0
     2     3     2     2

triu(M)

ans =

     1     2     3     4
     0     6     7     8
     0     0     1     1
     0     0     0     2

v1 = [1 1 2]

v1 =

     1     1     2

v2 = [2 4 3]

v2 =

     2     4     3

skalarni_proizvod = dot(v1, v2)

skalarni_proizvod =

    12

vektorski_proizvod = cross(v1, v2)

vektorski_proizvod =

    -5     1     2

v3 = [1 1 5]

v3 =

     1     1     5

mjeseviti_proizvod = dot(v1, cross(v2, v3))

mjeseviti_proizvod =

     6

v = [1 2 2]

v =

     1     2     2

v_norma = norm(v)

v_norma =

     3

v

v =

     1     2     2

normiran_v = v / v_norma

normiran_v =

    0.3333    0.6667    0.6667

norm(normiran_v)

ans =

     1

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

eig(M)

ans =

   12.1349
    0.0000
   -0.5848
   -1.5501

K

K =

     1     2     3
     2     2     0

eig(K)
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('eig')" style="font-weight:bold">eig</a>
Input matrix must be square.
} 
A = [1 2 3; 0 2 0; 0 1 1]

A =

     1     2     3
     0     2     0
     0     1     1

eig(A)

ans =

     1
     1
     2

help eig
 <strong>eig</strong>    Eigenvalues and eigenvectors.
    E = <strong>eig</strong>(A) produces a column vector E containing the eigenvalues of 
    a square matrix A.
 
    [V,D] = <strong>eig</strong>(A) produces a diagonal matrix D of eigenvalues and 
    a full matrix V whose columns are the corresponding eigenvectors  
    so that A*V = V*D.
  
    [V,D,W] = <strong>eig</strong>(A) also produces a full matrix W whose columns are the
    corresponding left eigenvectors so that W'*A = D*W'.
 
    [...] = <strong>eig</strong>(A,"nobalance") performs the computation with balancing
    disabled, which sometimes gives more accurate results for certain
    problems with unusual scaling. If A is symmetric, <strong>eig</strong>(A,"nobalance")
    is ignored since A is already balanced.
 
    [...] = <strong>eig</strong>(A,"balance") is the same as <strong>eig</strong>(A).
 
    E = <strong>eig</strong>(A,B) produces a column vector E containing the generalized 
    eigenvalues of square matrices A and B.
 
    [V,D] = <strong>eig</strong>(A,B) produces a diagonal matrix D of generalized
    eigenvalues and a full matrix V whose columns are the corresponding
    eigenvectors so that A*V = B*V*D.
 
    [V,D,W] = <strong>eig</strong>(A,B) also produces a full matrix W whose columns are the
    corresponding left eigenvectors so that W'*A = D*W'*B.
 
    [...] = <strong>eig</strong>(A,B,"chol") is the same as <strong>eig</strong>(A,B) for symmetric A and
    symmetric positive definite B.  It computes the generalized eigenvalues
    of A and B using the Cholesky factorization of B.
 
    [...] = <strong>eig</strong>(A,B,"qz") ignores the symmetry of A and B and uses the QZ
    algorithm. In general, the two algorithms return the same result,
    however using the QZ algorithm may be more stable for certain problems.
    The flag is ignored when A or B are not symmetric.
 
    [...] = <strong>eig</strong>(...,OUTPUTFORM) optionally specifies the output format
    for the eigenvalues returned in D. OUTPUTFORM can be:
 
       "vector" - Each page of D is a column vector.
       "matrix" - Each page of D is a diagonal matrix.
 
    See also <a href="matlab:help eigs -displayBanner">eigs</a>, <a href="matlab:help pageeig -displayBanner">pageeig</a>, <a href="matlab:help condeig -displayBanner">condeig</a>, <a href="matlab:help ordeig -displayBanner">ordeig</a>.

    <a href="matlab:doc eig">Documentation for eig</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('eig')">Other uses of eig</a>

a = eig(A)

a =

     1
     1
     2

[V,D] = eig(A) 

V =

    1.0000   -1.0000    0.9623
         0         0    0.1925
         0    0.0000    0.1925


D =

     1     0     0
     0     1     0
     0     0     2

help linsolve
 <strong>linsolve</strong> Solve linear system A*X=B.
    X = <strong>linsolve</strong>(A,B) solves the linear system A*X=B using LU factorization 
    with partial pivoting when A is square, and QR factorization with 
    column pivoting otherwise. <strong>linsolve</strong> warns if A is ill conditioned (for 
    square matrices) or rank deficient (for rectangular matrices). 
  
    X = <strong>linsolve</strong>(A,B,OPTS) solves the linear system A*X=B using an
    appropriate solver as determined by the options structure OPTS. The
    fields in OPTS are logical values describing properties of the matrix
    A (see table below). By default, all fields in OPTS are false. <strong>linsolve</strong>
    does not test to verify that A has the properties specified in OPTS.
 
    [X,R] = <strong>linsolve</strong>(...) also returns R, which is the reciprocal of the
    condition number of A (for square matrices) or the rank of A (for
    rectangular matrices). If OPTS is specified, then R is the reciprocal
    of the condition number of A unless RECT is true and both LT and UT are
    false, in which case, R gives the rank of A. <strong>linsolve</strong> does not warn if
    A is ill conditioned or rank deficient.
 
    The possible field names in OPTS and their corresponding matrix
    properties are:
 
    Field Name : Matrix Property
    ------------------------------------------------
    LT         : Lower Triangular
    UT         : Upper Triangular
    UHESS      : Upper Hessenberg
    SYM        : Real Symmetric or Complex Hermitian
    POSDEF     : Positive Definite
    RECT       : General Rectangular
    TRANSA     : (Conjugate) Transpose of A
 
    The following describes which fields can be specified together:
 
    If LT is true, then UT, UHESS, and SYM must be false.
    If UT is true, then LT, UHESS, and SYM must be false.
    If UHESS is true, then LT, UT, SYM, and RECT must be false.
    If SYM is true, then LT, UT, UHESS, and RECT must be false.
    POSDEF can only be true if SYM is true.
 
    Example:
      A = triu(rand(5,3)); 
      x = [1 1 1 0 0]'; 
      b = A'*x;
      y1 = (A')\b
      opts.UT = true; 
      opts.TRANSA = true;
      y2 = linsolve(A,b,opts)
 
    See also <a href="matlab:help mldivide -displayBanner">mldivide</a>.

    <a href="matlab:doc linsolve">Documentation for linsolve</a>
    <a href="matlab:matlab.internal.language.introspective.overloads.displayOverloads('linsolve')">Other uses of linsolve</a>

A = [ - 1 2 3 ; 2 1 -2 ; 4 3 1]

A =

    -1     2     3
     2     1    -2
     4     3     1

B = [2 ; 2 ; 1]

B =

     2
     2
     1

X = linsolve(A, B)

X =

    -1
     2
    -1

1:2:8

ans =

     1     3     5     7

M

M =

     1     2     3     4
     5     6     7     8
     1     1     1     1
     2     3     2     2

M([1:2:8])

ans =

     1     1     2     1

sistem_sa_par
 
X =
 
conj(x)
conj(y)
conj(z)
 
 
A =
 
[lambda,      1,      1]
[     1, lambda,      1]
[     1,      1, lambda]
 
 
B =
 
       1
  lambda
lambda^2
 
 
v1 =
 
-(conj(lambda) + 1)/(conj(lambda) + 2)
 
 
v2 =
 
1/(conj(lambda) + 2)
 
 
v3 =
 
(conj(lambda) + 1)^2/(conj(lambda) + 2)
 
diary off
E = eye(4)

E =

     1     0     0     0
     0     1     0     0
     0     0     1     0
     0     0     0     1

E + 1

ans =

     2     1     1     1
     1     2     1     1
     1     1     2     1
     1     1     1     2

diag([40 30 9], 2)

ans =

     0     0    40     0     0
     0     0     0    30     0
     0     0     0     0     9
     0     0     0     0     0
     0     0     0     0     0

diag([40 30 9], 2) + ones(5)

ans =

     1     1    41     1     1
     1     1     1    31     1
     1     1     1     1    10
     1     1     1     1     1
     1     1     1     1     1

A1 = ones(2, 3)

A1 =

     1     1     1
     1     1     1

A2 = ones(2) + 1

A2 =

     2     2
     2     2

A3 = ones(3)*3

A3 =

     3     3     3
     3     3     3
     3     3     3

A4 = ones(3, 2) + 3

A4 =

     4     4
     4     4
     4     4

A = [ A1 A2 ; A3 A4]

A =

     1     1     1     2     2
     1     1     1     2     2
     3     3     3     4     4
     3     3     3     4     4
     3     3     3     4     4

A = [ A1 A2 ; A3 A4];
B = [ ones(1, 7) ; ones(1, 7) * 2 ; ones(1, 7) * 3 ]

B =

     1     1     1     1     1     1     1
     2     2     2     2     2     2     2
     3     3     3     3     3     3     3

sum(B)

ans =

     6     6     6     6     6     6     6

sum(B')

ans =

     7    14    21

B'

ans =

     1     2     3
     1     2     3
     1     2     3
     1     2     3
     1     2     3
     1     2     3
     1     2     3

z = max(sum(B'))

z =

    21

B

B =

     1     1     1     1     1     1     1
     2     2     2     2     2     2     2
     3     3     3     3     3     3     3

B(1, 1:end)

ans =

     1     1     1     1     1     1     1

B(1, :)

ans =

     1     1     1     1     1     1     1

B(2, :)

ans =

     2     2     2     2     2     2     2

B = [ ones(1, 7) ; ones(1, 7) * 2 ; ones(1, 7) * 3 ]

B =

     1     1     1     1     1     1     1
     2     2     2     2     2     2     2
     3     3     3     3     3     3     3

max( [ sum(B(1, :) sum(B(2, :) sum(B(3, :) ] )
 max( [ sum(B(1, :) sum(B(2, :) sum(B(3, :) ] )
                    ↑
{Invalid expression. Check for missing multiplication operator, missing or unbalanced
delimiters, or other syntax error. To construct matrices, use brackets instead of
parentheses.
} 
max( [ sum(B(1, :)) sum(B(2, :)) sum(B(3, :)) ] )

ans =

    21

diary off
