% TEORIE MATIC - CVIČENÍ 1
format compact
A=[2,3,1;-1,0,2]

A =

     2     3     1
    -1     0     2

A(1,2)

ans =

     3

A(1,:)

ans =

     2     3     1

A(2,:)

ans =

    -1     0     2

A(:,1)

ans =

     2
    -1

A(:,2)

ans =

     3
     0

s1=A(:,1)

s1 =

     2
    -1

s2=A(:,2)

s2 =

     3
     0

s3=A(:,3)

s3 =

     1
     2

r1=A(1,:)
r1 =
     2     3     1
r2=A(2,:)
r2 =
    -1     0     2
%Tatáž matice zapsaná pomocí řádkových nebo sloupcových vektorů:
Ar=[r1;r2]
Ar =
     2     3     1
    -1     0     2
As=[s1,s2,s3]
As =
     2     3     1
    -1     0     2
A
A =
     2     3     1
    -1     0     2
B=[4 2 3;-1 2 2;0 1 0]
B =
     4     2     3
    -1     2     2
     0     1     0
diag(B)
ans =
     4
     2
     0
diag(ans)
ans =
     4     0     0
     0     2     0
     0     0     0
diag(diag(B))
ans =
     4     0     0
     0     2     0
     0     0     0
A
A =
     2     3     1
    -1     0     2
diag(A)
ans =
     2
     0
A
A =
     2     3     1
    -1     0     2
A.'
ans =
     2    -1
     3     0
     1     2
zeros(2,3)
ans =
     0     0     0
     0     0     0
zeros(2)
ans =
     0     0
     0     0
zeros(A)
??? Error using ==> zeros
Size vector must be a row vector with integer elements.

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 ...]) is an M-by-N-by-P-by-...
    array of zeros.
    ZEROS(SIZE(A)) is the same size as A and all zeros.

    See also ONES.

% Takhle to má být správně, když chceme vytvořit nulovou matici
% téže velikosti jakou má existující matice A:
zeros(size(A))
ans =
     0     0     0
     0     0     0
ones(2,3)
ans =
     1     1     1
     1     1     1
1:10
ans =
     1     2     3     4     5     6     7     8     9    10
1:2:10
ans =
     1     3     5     7     9
size(A)
ans =
     2     3
E12=zeros(size(A)); E12(1,2)=1
E12 =
     0     1     0
     0     0     0
A=[2,1,-1;0,-2,3]
A =
     2     1    -1
     0    -2     3
B=[3,1,0,1;0,1,2,-1;2,1,0,-2]
B =
     3     1     0     1
     0     1     2    -1
     2     1     0    -2
C=A*B
C =
     4     2     2     3
     6     1    -4    -4
exit
