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

조회 수: 4 (최근 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 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