I have the following question:
Write a program that:
Starts by requesting an A matrix by keyboard.
Next, if the number of columns of A is odd, the last column of additional zeros must be added. From this moment matrix, A has an even number (n) of columns.
The program will divide the input matrix into two sub-matrices.
The first sub-matrix (A1) contains the first n / 2 columns of A. The second sub-matrix (A2) has the last n / 2 columns.
Finally, the program must calculate and write on the screen a matrix B that has the rows of A1 in the odd rows and those of A2 in the pairs.
Example code
A = input('Enter a matrix:')
% A = magic(5) % for example
[filA, colA] = size(A);
if rem(colA,2)==1
A = [A, zeros(filA,1)]
colA = colA + 1;
end
A1 = A(:, [1:colA/2])
A2 = A(:, [1+(colA/2):colA])
%B