How to split a 2xN matrix into multiple 2x2 matrices?

4 visualizaciones (últimos 30 días)
Hsin-Yen
Hsin-Yen el 19 de Mzo. de 2024
Respondida: Dyuman Joshi el 19 de Mzo. de 2024
How to split a 2xN matrix into multiple 2x2 matrices? and multiply them.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 19 de Mzo. de 2024
%Assuming N is a multiple of 2
y = randi(10, 2, 16)
y = 2×16
1 9 5 10 8 7 10 9 1 1 2 8 2 8 10 7 8 2 7 10 8 6 2 9 7 6 1 9 2 4 2 2
%Reshaping into 2x2 blocks
y = reshape(y, 2, 2, [])
y =
y(:,:,1) = 1 9 8 2 y(:,:,2) = 5 10 7 10 y(:,:,3) = 8 7 8 6 y(:,:,4) = 10 9 2 9 y(:,:,5) = 1 1 7 6 y(:,:,6) = 2 8 1 9 y(:,:,7) = 2 8 2 4 y(:,:,8) = 10 7 2 2
z = y(:,:,1);
for k=2:size(y,3)
z = z*y(:,:,k);
end
z
z = 2×2
91869728 73010288 83919184 66691864

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by