%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% VectorMatrix_practice.m
%
% purpose: practice vector and matrix 
%
% written by tancy 05/08/2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Question_01
% we generated a matrix called as mat
mat = [1:4; 3 11 7 2]

% what is the size of mat?
% what is the number(s) of mat(2,3)?
% what is the number(s) of mat(:,3)?

%% Question_02 
% Create a row vector that has the elements: 6, 8 ? 3 , 81, e2.5, 65 , sin(pi/3), and 23.05.
% hint: e=> exp


%% Question_03
% Create a row vector in which the first element is 0, and the last element is 42, 
% with an increment of 3 between the elements (0, 3, 6, ......, 42).

%% Question_04
% Create a column vector with 14 equally spaced elements 
% in which the first element is 3 and the last element is 36.

%% Question_05
% Using the colon symbol, create a 3 x 5 matrix 
% in which all the elements are the number 7.
% hint: ones

%% Question_06
% By hand (pencil and paper) write what will be displayed 
% if the following commands are executed by MATLAB. 
% Check your answers by executing the commands with MATLAB. 
a = 0:2:6 
b = [a a]  
c = [a;a]

%% Question_07
% The following vector is defined in MATLAB:
v = [2,7,-3,5,0,14,-1,10,-6,8]
% By hand (pencil and paper) write what will be displayed 
% if the following commands are executed by MATLAB. 
%Check your answers by executing the com- mands with MATLAB.
a = v(3:6) 
b = v([2,4:7,10]) 
c = v([9,3,1,10])
d = [v([1,3 5]);v([2,4,6]);v([3,6,9])]

%% Question_08
% Use matrix B to:
% a) Create a six-element column vector named ua that contains the elements
%    of the second and fourth columns of B.
% b) Create a five-element column vector named ub that contains the elements 
%    of the third row of B.

B = [15, 12, 9, 6, 3;
     2, 4, 6, 8, 10;
     6, 12, 18, 24, 30]


%% Question_09
% a) Calculate A + B and B + A to show that addition of matrices is commutative.
% b) Calculate A + (B + C) and (A + B) + C to show that addition of matrices is associative.
% c) Calculate 5(A + C) and 5A + 5C to show that, when matrices are multi- plied by a scalar, the multiplication is distributive.
% d) Calculate A? ( B + C ) and A? B + A? C to show that matrix multiplication is distributive.
% e) Calculate mean of A, B, C column and then sum of them.
% f) Generate a new A,B,C matrix which only contain values >=0


A = [5,2,4; 1,7,-3; 6,-10,0]
B = [11,5,-3;0,-12,4; 2,6,1]
C = [7,14,1; 10,3,-2;8,-5,9]


