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

4 次查看(过去 30 天)
How to split a 2xN matrix into multiple 2x2 matrices? and multiply them.

采纳的回答

Dyuman Joshi
Dyuman Joshi 2024-3-19
%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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by