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

2 ビュー (過去 30 日間)
Hsin-Yen
Hsin-Yen 2024 年 3 月 19 日
回答済み: Dyuman Joshi 2024 年 3 月 19 日
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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by