advertisement

% First ,define the vector A as a row vector beginning with the number 1, % and increasing by increments of 1 until 18. A = [1:1:18] % Next, use the reshape function to turn the vector into a 3 x 6 matrix B = reshape(A, 3, 6) % Finally, we create a nine-element column vector that contains the % elements of the first, third and fifth columns of B Ba = [B(:,1); B(:,3); B(:,5)] A = Columns 1 through 13 1 2 3 4 5 6 Columns 14 through 18 14 15 16 17 18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 B = Ba = 1 2 3 7 8 9 13 14 15 Published with MATLAB® R2014a 1 16 17 18 7 8 9 10 11 12