필터 지우기
필터 지우기

Dividing a big matrix into small matrices(or Multiply a portion of a matrix to another) to multiply it with a small matrix and after that re add them into the same position.

조회 수: 7 (최근 30일)
I have a matrix A(400x400) and B(2x2). I want to divide matrix 'A' into 2x2 matrices and multply it with matrix B. Later on Recombine all the matrices from the output into the same locations from where I separated from A.
Example
A = 1 2 3 4 5 6 . . . . B = 1 2
6 5 4 3 2 1 . . . . 3 4
3 2 1 6 5 4 . . . .
5 4 6 1 2 3 . . . .
.
.
I simple want 1 2 ; 6 5 from A to be multiplied with B and restored in the same position and then multiply 3 4 ; 4 3 with B and so on. I am a beginner. Thank you very much

채택된 답변

KSSV
KSSV 2022년 10월 8일
A = [1 2 3 4 5 6 ;
6 5 4 3 2 1 ;
3 2 1 6 5 4 ;
5 4 6 1 2 3] ;
B = [1 2 ; 3 4] ;
[m,n] = size(A);
k = [2 2];
C = mat2cell(A,k(1)*ones(m/k(1),1),k(2)*ones(n/k(2),1)) ;
[m,n] = size(C) ;
D = cell(m,n) ;
for i = 1:m
for j = 1:n
D{i,j} = C{i,j}*B ;
end
end
iwant = cell2mat(D)
iwant = 4×6
7 10 15 22 23 34 21 32 13 20 5 8 9 14 19 26 17 26 17 26 9 16 11 16

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by