MATLAB: Use 3×3 Matrix to create 9×15 Matrix.

matrix manipulation

What would be the simplest approach to use a 3×3 Matrix (the one in the left corner) to create this one (9×15).

Best Answer

Well here is one way:
% Define the 3 by 3 matrix.
array3x3 = [1 2 3; 4, 5, 6; 7, 8, 9];
% Create the top and middle bands.
band1 = repmat([array3x3, zeros(3)], 1, 3)
band2 = circshift(band1, 3, 2)
% Stack them vertically.
final9x15 = [band1(:, 1:15); band2(:, 1:15); band1(:, 1:15)]
Related Question