フィルターのクリア

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 Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by