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

4 views (last 30 days)
How to split a 2xN matrix into multiple 2x2 matrices? and multiply them.

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 19 Mar 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

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!