%Solutions to the exercises in session 1

%%Exersamples

%Define the matrix MatA:
MatA = [1:10; 10:10:100; 100:100:1000];

%Create the matrix MatI = eye(4)
MatI = eye(4);

%Create a matrix MatB with columns of MatA such that you can do MatB*MatI

%Here, MatI has 4 rows, so MatB must have 4 columns. We select the first
%four for simplicity
MatB = MatA(:,1:4);
%Then
MatB*MatI; %doesn't throw an error


%Add rows to MatA so that you can multiply MatI*MatA. The new rows must
%follow the pattern in MatA. 
%So here, MatI has 4 columns, so MatA must have four rows. We add one row:
MatA = [MatA; 1000:1000:10000]; % or A(4, :) = 1000:1000:10000;. Yes, really.
%Then
MatI*MatA; %doesn't throw an error


%Create the vector VecA with the second row of MatA. Then delete the values
%20 and 90 from it by assigning them to the empty vector []
VecA = MatA(2,:);
%By looking at VecA one can see that 20 and 90 are in positions 2 and 9,
%so:
VecA([2,9]) = [];
%You can do it also in two steps, but be careful: VecA(2) = []; VecA(8) =
%[]. After the first command, the 90 is now on the 8th position.


%Delete the extra rows created in MatA by assigning an empty vector to
%these rows:
MatA(4,:) = [];
